Hi all.
I have defined a plot thus:
par(mar=c(5,5,4,5),las=1, xpd=NA)
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
The problem with this graph is that the main title is missing and so is
the digit "1" at the abscissa position 1 - although the other abscissa
labels are all there as defined in the "axis" call.
Can anyone shed anylight on why this is? I'm using R 2.1 on OS X.
Thanks
Iain
--
Iain Gallagher
Institute for Infection & Immunology Research
Ashworth Laboratories
Kings Buildings
University of Edinburgh
Edinburgh
EH9 3JT
UK
(+44) 0131 651 3630
Iain Gallagher wrote:> Hi all. > > I have defined a plot thus: > > par(mar=c(5,5,4,5),las=1, xpd=NA) > 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 > > The problem with this graph is that the main title is missing and so is > the digit "1" at the abscissa position 1 - although the other abscissa > labels are all there as defined in the "axis" call. > > Can anyone shed anylight on why this is? I'm using R 2.1 on OS X.We cannot reproduce your example due to lack of the data, hence cannot help very much. I can only guess that the number at the x-axis is left out for space reasons, but don't know what happens with your title. Please read the posting guide which suggests to specify a minimal toy example that shows your problem. Uwe Ligges> Thanks > > Iain > >
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
--
Iain Gallagher
Institute for Infection & Immunology Research
Ashworth Laboratories
Kings Buildings
University of Edinburgh
Edinburgh
EH9 3JT
UK
(+44) 0131 651 3630
For anyone who's looked at my previously posted problem I have managed to solve the missing graph title by removing the main="Graph Title" call from my plot definition and adding a line defining the graph title as a "title" call. i.e. from >plot(Day, Ym1Imp, ylim=c(0,100), type="b", bty="l", main="Ym1 Expression", cex=1.3, xaxt="n", yaxt="n") #plot implant data to >plot(Day, Ym1Imp, ylim=c(0,100), type="b", bty="l", cex=1.3, xaxt="n", yaxt="n") #plot implant data >title(main="Ym1 Expression")# add title which for some reason works. Still have the missing abscissa value though :-( Iain
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