Do not want scientific notation on plot axis

user438602 picture user438602 · May 11, 2011 · Viewed 100.9k times · Source

I regularly do all kinds of scatter plots in R using the plot command.

Sometimes both, sometimes only one of the plot axes is labelled in scientific notation. I do not understand when R makes the decision to switch to scientific notation. Surprisingly, it often prints numbers which no sane human would write in scientific notation when labelling a plot, for example it labels 5 as 5e+00. Let's say you have a log-axis going up to 1000, scientific notation is unjustified with such "small" numbers.

I would like to suppress that behaviour, I always want R to display integer values. Is this possible?

I tried options(scipen=10) but then it starts writing 5.0 instead of 5, while on the other axis 5 is still 5 etc. How can I have pure integer values in my R plots?

I am using R 2.12.1 on Windows 7.

Answer

Greg Snow picture Greg Snow · May 11, 2011

Use options(scipen=5) or some other high enough number. The scipen option determines how likely R is to switch to scientific notation, the higher the value the less likely it is to switch. Set the option before making your plot, if it still has scientific notation, set it to a higher number.