From: Jim Lemon <jim at bitwrit.com.au>
Subject: Re: [R] bar and line plot
To: mazatlanmexico at yahoo.com
Cc: r-help at stat.math.ethz.ch
Date: Saturday, September 27, 2008, 4:48 AM
Felipe Carrillo wrote:
Hello All:
Using the below dataset how can I make a barplot
Date(X) and NumEggs(Y) by Site. Then plot
It seems really simple, but I am having a hard
Hi Felipe,
This might do what you want:
fdc<-read.table("fdc.dat",header=TRUE)
fdc$Date<-as.Date(fdc$Date,format="%Y-%m-%d")
library(plotrix)
par(mar=c(5,4,4,4))
barp(fdc$NumEggs,names.arg=fdc$Date,xlab="Date",ylab="Number
of eggs",
main="Number of eggs by date",col=fdc$Site)
# a low trick to align the x-axis for the temperature line
startDate<-as.Date("2008-04-21",format="%Y-%m-%d")
lines(fdc$Date-startDate,fdc$Temp/5)
axis(4,at=10:12,labels=c(50,55,60))
mtext("Temperature",side=4,at=5,line=1)
legend(2,14,levels(fdc$Site),fill=1:3)
Jim