[R] Help with plots

Sarah Chisholm sarah.chisholm.09 at ucl.ac.uk
Wed Aug 4 10:46:51 CEST 2010


Hi,

I am trying to plot several time series plots with R, but I can't seem to get the x-axis properly formatted. What I am doing at the moment is:

dates <- seq(as.Date("2007/06/10", "%Y/%m/%d"),
   as.Date("2010/03/28", "%Y/%m/%d"), 7)
par(mfrow=c(5,2))
plot(DateJonEnd1, End1Jon, main="Weekly Training at Endurance 1", xlab="Date",
   ylim=c(0,350), ylab="Volume at Endurance 1", type="b", xlim=c(13700,14750),
   las=1, xaxt="n")
axis.Date(1, End1Jon, dates, format="%m", padj=-1, tcl=-0.5)
axis.Date(1, End1Jon, dates, format="%y", tick=FALSE)
plot(Date500JonTime, Time500Jon, main="500m", ylim=c(41,45), xlab="Date",
   ylab="Time", type="b", xlim=c(13700,14750), las=1, xaxt="n")
axis.Date(1, Time500Jon, dates, format="%m", padj=-1, tcl=-0.5)
axis.Date(1, Time500Jon, dates, format="%y", tick=FALSE)
...
plot(DateJonVol, VolJon, main="Weekly Training Volume", xlab="Date",
   ylab="Total Volume", type="b", xlim=c(13700,14750), las=1, xaxt="n")
axis.Date(1, VolJon, dates, format="%m", padj=-1, tcl=-0.5)
axis.Date(1, VolJon, dates, format="%y", tick=FALSE)
mtext(expression(bold("Jon")), outer = FALSE, side=3, line=59.5, adj=-0.135,
   cex=2)

How can I get R to put one tick per month on the x-axis? At the moment R also tries to optimize the labelling of the x-axis, but I would like it to label every month and every year, but the year only once, not once per label, the way it is doing it now.

Also, is there any way of increasing the single graphs on the one sheet? At the moment the graphs look so small and there is so much space between the graphs that is not being used.

Thank you very much!


More information about the R-help mailing list