Hi Jim:
Thanks for your suggestion from the plotrix package. That's exactly what I was 
looking for, however, I can't see the dates along the X axis and neither the 
temp line (I only see the thicks). Is there a way to actually plot the temp 
line? I have been using the ggplot2 package and I am able to do a barplot for 
my NumEggs(max value is 14) but I can't plot the temp data because the scales 
are way different (the max value is around 55-60). I guess I could try to plot 
the temp separately and put the graphs side by side. Thanks Jim. 

> From: Jim Lemon <[EMAIL PROTECTED]>
> Subject: Re: [R] bar and line plot
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Date: Saturday, September 27, 2008, 4:48 AM
> Felipe Carrillo wrote:
> >  Hello All:
> >     Using the below dataset how can I make a barplot
> with
> >     Date(X) and NumEggs(Y) by Site. Then plot
> Temp(lineplot)
> >     It seems really simple, but I am having a hard
> time trying to
> >     do it by Site. Thanks
> >   
> 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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to