[R] Y-axis label not plotting

Jim Lemon jim at bitwrit.com.au
Wed Nov 27 11:23:19 CET 2013


On 11/27/2013 05:32 PM, Luke M wrote:
> Dear R community
>
> I am trying to make an XY plot that shows temperature (y axis) as a
> function of time (x axis) but I am having some problems. When I use the
> code shown below:
>
> 1. my plot does not show any of the y-axis labels even though there is
> plenty of white space there (i.e.: I am getting no y-axis title, and no
> y-axis labels at each tick mark). Is my command syntax incorrect?
>
> 2. Also, I was wondering... is there a way to tell R to plot the last 30
> days of data in the x-axis?
>
>
> Thank you so much in advance!!
>
>
> Here's my code so far:
>
> bdata=read.table('cleandata.asc',header=FALSE)
> dates1<- strptime(paste(bdata$V2, bdata$V3), format="%m/%d/%Y %H:%M:%S")
> temp1 = bdata[,4]
> par(mar=c(5, 6, 4, 2))
> plot(dates1, temp1,type="o",col="red",pch=20,xlab="x axis", main="my plot",
> ylab="y axis", ylim=c(0,40), yaxp = c(0,40,10))
>
>
> PS: just fyi, my data looks like this:
>
Hi Luke,
Thanks for including the data. When I plot it, I get both y axis label 
and y axis tick labels.

If you only want the last 30 days, you could select them like this:

last30<-dates1 >= strptime("2013-10-14","%Y-%m-%d")
plot(dates1[last30],temp1[last30],type="o",col="red",pch=20,
  xlab="x axis", main="my plot", ylab="y axis", ylim=c(0,40),
  yaxp = c(0,40,10))

Jim



More information about the R-help mailing list