[R] axis labels defaulting to scientific notation
Jim Lemon
jim at bitwrit.com.au
Wed Aug 11 13:20:40 CEST 2010
On 08/11/2010 06:18 AM, Watkins, Janice wrote:
> The labels on the x-axis are defaulting to scientific notation no matter
> how small cex.axis is. How can I override scientific notation to get the
> labels to print out as specified? Here is the code (UNIT here is
> 0.0105):
>
> plot(xm,yv,log="xy",ylim=c(0.1,20)/UNIT,xlim=c(0.004,20)*UNIT,xaxt="n",t
> ype="n")
>
> axis(1, at=c(0.0001,0.001,0.005,0.01,0.05,0.5,0.1,1),cex.axis=0.7)
>
>
Hi Janice,
Have a look at the "scipen" option. This forces output format toward
either fixed or exponential notation depending on the value. Roughly, if
scipen is set to zero (the default), the output format will be whichever
had the fewest characters. If you set it to a positive number:
options(scipen=3)
you will probably get the fixed notation in your plot, as the
exponential notation will always be longer. To go the other way, set
scipen to a negative number.
Jim
More information about the R-help
mailing list