0

I am using the xyplot in lattice trying to make a plot that shows temperature change over time in correlation with count data. I am not sure if ggplot2 would be better? My data is arrange like this:

Year (1998  1998 1999 2000 2001 2001 2002)  
Low (2.777778  8.333330  10.555556 4.444444 26.388889 15.555556 12.500000)    
Geese (2 14 10 16 7 10 15)    
State (Arkansas California California California California Florida California)  

I am stuck at this part of the code:

xyplot(c(geese,low)~year,subset=state=="California", par.settings=bwtheme, auto.key=TRUE)

The plot has the geese and low (temperature) as the same type of point and if I add a line there is no separation between the two. Please any help for this would be awesome.

Andre Silva
  • 4,782
  • 9
  • 52
  • 65
  • Do you want 'year' in the x axis, 'low' in one y axis and 'geese' in another y axis? What about the State information? How would you like to represent it? Can you show a similar graph to represent the desired output? – Andre Silva Jul 01 '14 at 01:01
  • That's NOT code that will create a data object in R. And ... What is `bwtheme`? If it's from some other package, you should add code to load that package. And further ... why label a question bout xyplot with a 'ggplot2' tag? – IRTFM Jul 01 '14 at 01:02
  • Did you just want `xyplot(geese+low~year,subset=state=="California",auto.key=TRUE, type="b")`? – MrFlick Jul 01 '14 at 03:59
  • MrFlick, that completely answered my questioned. I had to geese+low, not c(geese,low). Thank you so much – eggo_chesbro Jul 01 '14 at 16:40
  • @MrFlick, you could post your comment as an answer. – Andre Silva Jul 02 '14 at 16:04

1 Answers1

0

To plot multiple series on the same plot, use + rather than c() to specify multiple y values. For example

xyplot(geese + low ~year, subset=state=="California", auto.key=TRUE, type="b")

That will produce

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295