[R] plot - no main title and missing abscissa value
Uwe Ligges
ligges at statistik.uni-dortmund.de
Mon Oct 10 23:09:43 CEST 2005
Iain Gallagher wrote:
> Hi. Sorry (esp to Uwe for the repeated messages!)
>
> Here is the data and my code in full. Thanks for the
> help.
>
> Data.
>
> Day Ym1Imp Ym1sham Semimp Semsham
> 0 5.78 5.78 1.22 1.36
> 1 44.36 42.1 16.26 18.83
> 3 38.39 14.66 18.02 2.86
> 5 57.76 1.03 15.28 0.29
> 7 72.93 2.71 18.6 1.06
> 10 48.57 4.61 11.26 5.21
> 14 74.08 1.53 9.66 0.11
> 21 73.86 0.14 7.2 0.02
>
>
> Code
>
> ym<- read.table("ym1expression.csv", header=T,
> sep="\t", quote="\"") #read in ym data
> attach(ym)# make data visible to R
> par(mar=c(5,5,4,5),las=1, xpd=NA)
> x<- c(0,1,3,5,7,10,14,21)
> plot(Day, Ym1Imp, ylim=c(0,100), type="b", bty="l",
> main="Ym1 Expression", cex=1.3, xaxt="n", yaxt="n")
> #plot implant data
> axis(side=1, at=c(0,1,3,5,7,10,14,21),
> labels=c(0,1,3,5,7,10,14,21)) # label x axis
> mtext("Day", side =1, at=10, line=3, cex=1.2) # title
> x axis
> mtext("AU", side=2, at=50, line=3, cex=1.2)# y axis
> title
> axis(side=2, at=c(0, 25, 50, 75, 100),
> labels=expression("0", "25", "50", "75", "100")) #
> label y axis
> arrows(x, Ym1Imp-Semimp, x, Ym1Imp+Semimp, code=3,
> angle=90, length=0.1)# place error bars
> points(Day, Ym1sham, type="b", pch=16, cex=1.3)# plot
> sham data
> arrows(x, Ym1sham-Semsham, x, Ym1sham+Semsham, code=3,
> angle=90, length=0.1)# plot sham error bars
> legend(20, 60, legend="Implant", pch=1, lty=1,
> bty="n")# implant legend
> legend(20, 50, legend="Sham", pch=16, lty=1, bty="n")#
> sham legend
>
> Iain
>
Three points:
1. The main title appears for me under the Windows device. I really
wonder why you do not see it, this seems to be quite a strange device
dependence I would not expect in this case.
Since you told us you have "R 2.1", we do not know exactly what you have
got - there is no such version. There are versions R-2.0.1, R-2.1.0 and
R-2.1.1, though. Anyway, you told us you found a workaround.
2. In order to re-plot the axis labels, you should specify xlab=NA,
ylab=NA in your call to plot() as in:
plot(Day, Ym1Imp, ylim=c(0,100), type="b", bty="l", xlab=NA, ylab=NA,
main="Ym1 Expression", cex=1.3, xaxt="n", yaxt="n")
3. As I have already guessed, the axis annotation of the tick at
position 1 is left out because R thinks there is not enough space left.
You can workaround this point by making the label appear separately as in:
axis(side=1, at=c(0,3,5,7,10,14,21))
axis(1, 1)
Uwe Ligges
More information about the R-help
mailing list