[R] X-axis labels not displayed when changing ylim
Sarah Bonnin
sarah.bonnin at crg.es
Thu Jul 9 17:36:42 CEST 2009
Dear R users,
I am encountering a x axis labeling problem on quite basic plots...
I use the following code which displays the labels on the x-axis with a
45 degrees angle:
p <- plot(myobject1, type="b", col="red",cex=1, lwd=2, axes=FALSE,
ann=FALSE, ylim=c(0,70))
title(main="title", font.main=4)
axis(side=1, lab=F)
text(axTicks(1), par("usr")[3] - 2, srt=45, adj=1,labels=mylabels,xpd=T,
cex=0.8, font=2)
axis(side=2, las=1, cex.axis=0.8, font=2)
I set up the ylim from 0 to 70 for plotting that object "myobject1" ->
works well.
However, when i try to use the same script with another set of data
"myobject2" (same number of points, same labels, but different
values...) that ranges from 0 to 2 (ylim changed to "c(0,2)"), the
labels on the x axis disappear...
When i try to run the same lines for "myobject2" but putting the ylim
higher "c(0,50)", the labels on the x axis are displayed.
I picked up some pieces of code here and there so i may do an obvious
mistake but cannot figure out what it is! I tried to modify the text
parameters "adj" or "par("usr")...", unsuccessfully...
I hope i made it clear, there must be a scaling problem that i really
don't get...
I run R 2.8.0 under Windows XP Pro.
Thank you for your help!
Sarah
More information about the R-help
mailing list