0

I would like to do a plot in R (using the plot function) with log scale on Y axis which shows on the y axis only the power of 10 in a style like 10, 100, 1000... Is it possible ? I do not like the solution with xant="n" or yant="n" , explained here, which suppress x-axis or y-axis, because if I use a code like:

plot(x33,y33,log = "x",xaxt="none",xlab =xlab.text ,ylab = "Signal Density (a.u.)",main=expression('Relaxation times distribution - H'[2]*'O'),
     las=1,cex.main=1,font.main=2,font.lab=2, cex.lab=0.9, cex.axis=0.7,type = "l",lwd=1.5,
     col="red",ylim = c(0,2000))

axis(1, 10^seq(0L,6L,2L),cex.axis=0.7)

it shows me axis with 1e+00,1e+02...and I do not like this format. If I use the same code with seq() instead of 10^seq(0L,6L,2L), how can I say it to print only powers of 10 ? I know xant and yant are the straightforward solution but I do not know how to use them such that I can print 10, 100, 1000...

  • https://stackoverflow.com/questions/4699493/transform-only-one-axis-to-log10-scale-with-ggplot2 – TTS Dec 17 '20 at 18:51
  • If you want fine control over the axis of a base plot, I'm not aware of any way other than suppressing the axis in the original `plot()` call and then specifying how you want it to appear with `axis()`. Can you say more about what you "do not like" about that solution? – Gregor Thomas Dec 17 '20 at 18:53
  • @GregorThomas you are right. I modified the post to make what I mean clear. –  Dec 18 '20 at 08:31

1 Answers1

1

This post appears to answer your question. The log scale is applied to the x axis in this example, so just change that to y axis.

Logarithmic scale plot in R

  • Hi thank you but, as I wrote in the post that I have modified, I do not really like the format with 1e+00,1e+02 etc... :( I would like to say it to print 10, 100,1000... –  Dec 18 '20 at 08:34
  • With `axis` you can use the `labels` and `at` arguments to specify exactly the labels you want at the locations you want. – Gregor Thomas Dec 18 '20 at 14:22