Data visualization with SAS programming

Displaying 0 on log axis

Reply
Contributor
Posts: 37

Displaying 0 on log axis

 

I want to display "0" as a tick on y-axis. The y-axis in my plot is log axis.

The ticks I have currently are 1E1, 1E2, etc. I am using SAS 9.4M2.

Is there any way to display 0 tick on the y-axis ?

 

Grand Advisor
Posts: 9,748

Re: Displaying 0 on log axis

You need to provide a bit more detail of the code generating the graph as there may be different options available depending on your approach or procedure used.

SAS Super FREQ
Posts: 3,232

Re: Displaying 0 on log axis

You can't display 0 on a log-scale axis because log(0) is undefined.

 

You can display 1E-6, which is 6 units to the left of 1.

You can display 1E-10, which is 10 units to the left of 1.

You can display 1E-16, which is 16 units to the left of 1 and is about the limit of many numerical computations.

 

Contributor
Posts: 37

Re: Displaying 0 on log axis

Thanks. 

Does format works on log axis in 9.4M2 ? 

SAS Super FREQ
Posts: 1,044

Re: Displaying 0 on log axis

[ Edited ]

First, let me say I agree with Rick that one should not display a '0' on  a log axis.  Having said that, if you really want to do that, you can use a format to display the lowest value as '0' as shown below.  Or, with SAS 9.40M3, you can use special Unicode values in your format to display the smallest value as "approximately" 0 :-)

 

LogZero.png

 

data log;
input x y;
datalines;
1 0.1
2 1
3 10
4 10000
5 10000000
;
run;

 

proc format;
  value logzero
    0.0001="(*ESC*){unicode '2248'x} 0"
    1='1'
    1000='1000'
    1000000='1000000'
;
run;

 

ods html close;
ods listing gpath='C:\Work\SASUser' image_dpi=200;
ods graphics / reset width=5in height=3in imagename='LogZero';
proc sgplot data=log;
  format y logzero.;
  scatter x=x y=y;
  yaxis type=log logbase=10 min=0.0001 grid
           values=(0.0001 1 1000 1000000) ;
run;

Contributor
Posts: 37

Re: Displaying 0 on log axis

Thank you all for all the answers. I ended up doing the log transformation first and then using linear scale.

I used format to display values I needed. 

SAS Super FREQ
Posts: 3,232

Re: Displaying 0 on log axis

Just to warn you, if you intend to show this graph to someone else, they might notice that it makes no sense.

Contributor
Posts: 37

Re: Displaying 0 on log axis

Thanks Rick. Not using log..it is linear. 

Post a Question
Discussion Stats
  • 7 replies
  • 278 views
  • 2 likes
  • 4 in conversation