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:
> temp1
[1] 6.81 26.81 26.81 26.81 26.87 26.87 26.87 26.87 27.06 27.06 27.06
27.06
[13] 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06
27.06
[25] 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06 27.06
27.06
[37] 27.06 27.06 27.06 27.06 27.06 27.00 27.00 27.06 27.06 27.06 27.00
27.00
[49] 27.06 27.00 27.00 27.00 27.00 27.00 27.00 27.00 27.00 26.94 26.94
26.94
[61] 26.94 27.00 26.94 26.94 26.94 26.94 26.94 26.94 26.94 26.94 26.94
27.00
[73] 26.94 26.94 26.94 26.94 26.94 26.94 26.94 26.94
26.94>
>
> dates1
[1] "2013-01-12 18:10:28 HST" "2013-10-24 18:10:43 HST"
[3] "2013-10-29 18:10:49 HST" "2013-11-14 18:10:52 HST"
[5] "2013-11-14 18:12:10 HST" "2013-11-14 18:12:12 HST"
[7] "2013-11-14 18:12:21 HST" "2013-11-14 18:12:22 HST"
[9] "2013-11-14 18:17:10 HST" "2013-11-14 18:17:11 HST"
[11] "2013-11-14 18:17:13 HST" "2013-11-14 18:17:14 HST"
[13] "2013-11-14 18:17:15 HST" "2013-11-14 18:17:17 HST"
[15] "2013-11-14 18:17:18 HST" "2013-11-14 18:17:20 HST"
[17] "2013-11-14 18:17:21 HST" "2013-11-14 18:17:22 HST"
[19] "2013-11-14 18:17:24 HST" "2013-11-14 18:17:25 HST"
[21] "2013-11-14 18:17:26 HST" "2013-11-14 18:17:28 HST"
[23] "2013-11-14 18:17:29 HST" "2013-11-14 18:17:30 HST"
[25] "2013-11-14 18:17:32 HST" "2013-11-14 18:17:33 HST"
[27] "2013-11-14 18:17:34 HST" "2013-11-14 18:17:36 HST"
[29] "2013-11-14 18:17:37 HST" "2013-11-14 18:17:38 HST"
[31] "2013-11-14 18:17:40 HST" "2013-11-14 18:17:41 HST"
[33] "2013-11-14 18:17:42 HST" "2013-11-14 18:17:44 HST"
[35] "2013-11-14 18:17:45 HST" "2013-11-14 18:17:46 HST"
[37] "2013-11-14 18:18:47 HST" "2013-11-14 18:18:48 HST"
[39] "2013-11-14 18:18:50 HST" "2013-11-14 18:18:51 HST"
[41] "2013-11-14 18:18:52 HST" "2013-11-14 18:18:54 HST"
[43] "2013-11-14 18:18:55 HST" "2013-11-14 18:18:56 HST"
[45] "2013-11-14 18:18:58 HST" "2013-11-14 18:18:59 HST"
[47] "2013-11-14 18:19:10 HST" "2013-11-14 18:19:11 HST"
[49] "2013-11-14 18:19:12 HST" "2013-11-14 18:19:14 HST"
[51] "2013-11-14 18:19:15 HST" "2013-11-14 18:19:16 HST"
[53] "2013-11-14 18:19:18 HST" "2013-11-14 18:19:19 HST"
[55] "2013-11-14 18:19:20 HST" "2013-11-14 18:19:22 HST"
[57] "2013-11-14 18:19:23 HST" "2013-11-14 18:20:24 HST"
[59] "2013-11-14 18:20:26 HST" "2013-11-14 18:20:27 HST"
[61] "2013-11-14 18:20:29 HST" "2013-11-14 18:20:30 HST"
[63] "2013-11-14 18:20:31 HST" "2013-11-14 18:20:33 HST"
[65] "2013-11-14 18:20:34 HST" "2013-11-14 18:20:35 HST"
[67] "2013-11-14 18:20:37 HST" "2013-11-14 18:20:38 HST"
[69] "2013-11-14 18:20:39 HST" "2013-11-14 18:20:41 HST"
[71] "2013-11-14 18:20:42 HST" "2013-11-14 18:20:43 HST"
[73] "2013-11-14 18:20:45 HST" "2013-11-14 18:20:46 HST"
[75] "2013-11-14 18:20:47 HST" "2013-11-14 18:20:49 HST"
[77] "2013-11-14 18:20:50 HST" "2013-11-14 18:20:51 HST"
[79] "2013-11-14 18:20:53 HST" "2013-11-14 18:20:54 HST"
[81] "2013-11-14 18:20:55 HST"
[[alternative HTML version deleted]]
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