Skip to content
Prev 167177 / 398502 Next

XYplot in Lattice Package

Dear R-Users

I have 2 questions to do with XYplot.  

1)

I am trying to use the XYplot function to generate multiple line graphs with
the legend outside the plot.
I am using the following loop for each graph:

library(lattice)

for (i in x.sp){
xyplot(Catch~Year, df, groups = Stock, type="a",auto.key =
       list(space = "top", points = FALSE, lines = TRUE,columns = 4))
}

When I run the script I don't get any output graphs, however if I change
'XYplot' to 'plot', or generate the plots manually using XYplot, It seems to
work.  Is there a bug of some sort or is it me?

2)

How do I remove the "top" and "right" axis from a plot?  If I add 'axis(side
= c("bottom", "left")' to the xyplot call it comes up with the message:
   
Error in axis(side = c("bottom", "left")) : 
  plot.new has not been called yet

Any help is much appreciated :)