Hello 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 http://sneakymustard.com/tmp/plot.jpg 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)) or 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, Andre
Andre Nathan <andre <at> digirati.com.br> writes:> > Hello > > 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")) >Hmmm. What do you mean by "not very nice"? This graph seems (to me) to be a typical logarithmic scaling axis. If you really wanted equal scaling you could do matplot(...,axes=FALSE) axis(side=1) pvec <- 10^seq(-3,-1,by=0.5) axis(side=2,at=pvec,labels=round(pvec,3)) box() or something like that... warning, totally untested ... (the only way I can think of to get "pretty" and equally spaced ticks is to use ONLY powers of ten ...) Ben Bolker
On Thu, 2006-11-02 at 23:10 +0000, Ben Bolker wrote:> If you really wanted equal scaling you could do[...] Thanks Ben. Do you know how the the x axis can be made shorter? Best regards, Andre
Andre Nathan <andre <at> digirati.com.br> writes:> Thanks Ben. Do you know how the the x axis can be made shorter?If you want to shorten the x interval, use xlim=c(0,750) Otherwise, if you want to decrease the physical width of your plot, you should use the width= argument in call to "png", when initializing your plotting device.