[R] ploting axes and rotating strings
MSchwartz at MedAnalytics.com
Wed Oct 27 16:29:24 CEST 2004
On Wed, 2004-10-27 at 08:34, AleÅ¡ Å½iberna wrote:
> I have two question that rose from trying to tacle the same problem in two
> differnet ways.
> What I want to do is to plot axes (only values or labels, no tick marks) in
> such a way that 'cex' can be very small, text can be perpendicular to the
> axis (as in axis(las=2) ) and the text is stil at the right position.
> Let me demonstrate with a small example:
> The text on the axis should be at the same points as tick marks, but it is
> shifted right.
> I tried to bypas the problem by using function 'text', which puts the text
> at the correct positions, however, it has another problem. I would like to
> rotate the text, but if I use 'str=90' (to rotate the text for 90 degrees),
> I get a warning massage:
> Warning message:
> parameter "str" couldn't be set in high-level plot() function
> This suprises me, since if I read the help correctly ('?par'), then this
> should not happen.
> So if anyone can either hepl me to rotate the text in 'text' or to correctly
> plot the text in 'axis', I would be very grateful.
I am not able to replicate the right-shift of the text labels. It may be
a visual screen artifact of the small font size you are using. If you
increase the cex.axis to 0.25 (for example), it becomes clear that the
labels are in the proper position.
I put up a PDF containing the plot at:
I used the following code:
plot(0:100/100, 0:100/100, axes = FALSE)
axis(side = 3, at = 0:100/100, labels = 0:100, las = 2, cex.axis = 0.1)
axis(side = 1, at = 0:100/100, labels = 0:100, las = 2, cex.axis = 0.25)
I'll leave that up for a bit for review. I presume that you have the
Acrobat Reader under Windows?
Relative to the use of text() for rotating axis labels, see:
More information about the R-help