parvin karimi parvin karimi - 4 years ago 172
R Question

Y axis not showing values correctly R plot

I'm wondering what is the fix for my Y axis in my plot below? Y axis is supposed to be comprised of of SEVEN values (.1, 1, 10, 100, 1000, 10000, 1000000)? But they don't show correctly on the plot?

Here is my R code?

plot(1, 1, type = "n", xlim = c(0,1.5), ylim = c(.1, 100000), ann=F,bty="n",yaxt="n")

axis(side=2, at = 10^(-1:5),label=c(format(10^(-1:5),scientific=F) ))

Answer Source

You need to specify the y axis as a logarithmic scale with the log="y" parameter:

plot(1, 1, type = "n", xlim = c(0,1.5), ylim = c(.1, 100000), ann=F, bty="n", log="y", yaxt="n")
axis(side=2, at = 10^(-1:5),label=c(format(10^(-1:5),scientific=F) ) )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download