[R] Better y-axis labels, and x-axis scaling

Andre Nathan andre at digirati.com.br
Thu Nov 2 22:08:49 CET 2006


I'm plotting some data using matplot with a logarithmic scale on the
y-axis. This is the call to matplot I'm using:

  matplot(turns, distances, type = "l", log = "y", lty = "solid",
          ylab = "", xlab = "Time steps", col = c("black"))

The values for the 'distances' vector are always between 0 and 1.

The result can be seen at


As you can see, the default y axis labels are not very nice, as it uses
irregular intervals.

I tried using variations of

  axis(2, at = pretty(c(0, ceiling(max(distances))), 5))


  yaxp = c(round(mind, 2), round(maxd, 2), -4)

in the matplot() call.

Is there anything else I could try for better labeling of values between
0 and 1 in a log-scale axis? Hints or pointers to the appropriate docs
are appreciated :)

Also, is there a command/option to change the plotted spacing between
the labels in a plot? In the plot above, I'd like to make the space
between each label in the x-axis smaller (maybe something similar to the
width/space options in barplot()).

Thanks in advance,

More information about the R-help mailing list