[R] XYplot in Lattice Package

jimdare jamesdare26 at gmail.com
Mon Jan 19 23:07:02 CET 2009


Thanks for your help David.   I managed to track down this solution in regard
to the second question:

http://www.nabble.com/lattice-xyplot-with-bty%3D%22l%22-tt12486052.html#a12489170

Regards,
James






David Winsemius wrote:
> 
> 
> On Jan 15, 2009, at 9:27 PM, jimdare wrote:
> 
>>
>> 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))
>> }
>   From the help on package lattice:
> "Note
> High level Lattice functions (like xyplot) are different from  
> conventional R graphics functions because they don't actually draw  
> anything. Instead, they return an object of class "trellis" which has  
> to be then printed or plotted to create the actual plot. This is  
> normally done automatically, but not when the high level functions are  
> called inside another function (most often source) or other contexts  
> where automatic printing is suppressed (e.g. for or while loops). In  
> such situations, an explicit call to print or plot is required."
> 
> 
> 
> Or the FAQ:
> 
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
> 
> 
> 
>>
>>
>> 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?
> 
> It's you.
> 
>>
>>
>> 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
> 
> see at the top of the axis help page:
> 
> "axis {graphics}" so axis is not part of lattice
> 
> Had you continued reading the next sentence in the lattice intro help  
> page, you would have seen:
> 
> "Lattice plots are highly customizable via user-modifiable settings.  
> However, these are completely unrelated to base graphics settings; in  
> particular, changing par() settings usually have no effect on lattice  
> plots."
> 
> 
> Try:
> http://stat.ethz.ch/R-manual/R-patched/library/lattice/html/axis.default.html
> 
> And chapter 8 of:
> 
> http://lmdvr.r-forge.r-project.org/figures/figures.html
> 
> Best of luck and buy Sarkar's book.
> David Winsemius
> 
> 
> 
>>
>>
>> Any help is much appreciated :)
>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/XYplot-in-Lattice-Package-tp21491296p21491296.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at 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.
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/XYplot-in-Lattice-Package-tp21491296p21552650.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list