What about privacy ? :)

Sign by Danasoft - For Backgrounds and Layouts

martedì 16 aprile 2013

LATTICE package intro

This post is a sort of pro-memoria where I wrote down the main concepts of one chapter of the Murrel book reported in the bibliography, at the end of the post. The LATTICE package implements the Trellis graphic system, you can find information here.
It is based on the "grid system" of plotting (not on the "base system"). Anyway, it can be used without tackle any of the underlying grid concepts. In fact, it is also a self-contained system with a set of functions for:
  • producing complete plots;
  • controlling the appearance;
  • opening/closing devices.
Lattice functions produce an object of class "trellis", containing a descriprtion of the plot. The actual draw is performed by the print() function.

tpl <- xyplot(lat ~ long, data=quakes) # creates a trellis object
print(tpl) # draw it

Now it is possible to modify the trellis object through the update() method, which is an alternative to modifying the original R expression used to create the trellis object.

update(tplot, main="This is a Title\n(write what you prefer)") # insert a title

Note:
  • A subtle change: extra space introduced to allow room for adding the new main title.
  • this change is not retained: ion order to retain it you should assign to the object
tplot <- update(tplot, main="This is a Title\n(write what you prefer)") # insert a title


Different devices have different default settings (e.g.: PDF has different settings compared to PNG). The first time that a lattice output is produced the settings are initialized (type ?trellis.device() ).
The graphical appearance of lines type and colors, text fonts etc. are maintained for each device opened (more on next posts). Default settings of Trellis Graphics produced through Lattice are carefully selected in order to maximize the
readability based on principles of human perception.

Bibliography
Murrell. P., R Graphics, 2005 by Chapman and Hall/CRC ( Murrel book web page )

Nessun commento:

Posta un commento