[R] pie chart in lattice - trellis class

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Mon May 28 09:53:02 CEST 2007


Deepayan Sarkar a écrit :
> On 5/27/07, Patrick Giraudoux <patrick.giraudoux at univ-fcomte.fr> wrote:
>> Dear all,
>>
>> After going through the Lattice doc and R-help list and google, I got
>> the feeling that there is no function in lattice or other package to
>> compute a pie chart object  of class "trellis". Although pie charts are
>> obviously not considered optimal even in the pie() doc ;-) ,  pie chart
>> trellis objects would be easy positioned e.g. over a map drawn with the
>> grids package.
>>
>> Can anybody confirm this absence or indicate a package/function able to
>> draw a pie chart  object of class trellis?
>
> I can confirm that lattice does not produce "trellis" objects
> representing pie charts (although I guess it can be made to do so with
> a user supplied panel function). However, I don't see how that would
> have helped you with the map example, as plotting a "trellis" object
> would also include the axes, labels, etc. What you really want is the
> ability to draw a circle with differently colored angular segments,
> which can be reasonably approximated by polygons. polygon() and
> grid.polygon() do these for traditional and grid graphics
> respectively.
>
> -Deepayan
>
>
Yes indeed. Thats' likely what I am going to do. Anyway, to plot axes, 
labels of sophisticated graphs on maps may be interesting anyway. For 
instance, we are monitoring fox and hare populations in tens of game 
areas. Drawing observations (panel.xyplot) over time and representing 
the trend variations (panel.loess) at the very place on the map where 
the observations were done gives an absolutely interesting view where 
spatial relationships between trends can be visualized.

Patrick



More information about the R-help mailing list