# [R] squared "pie chart" - is there such a thing?

Sarah Goslee sarah.goslee at gmail.com
Thu Jul 21 18:20:14 CEST 2011

```On Thu, Jul 21, 2011 at 12:06 PM, Dimitri Liakhovitski
<dimitri.liakhovitski at gmail.com> wrote:
> I tried the mosaic chart:
>
> mytotal=data.frame(x=50,y=30,z=20)
> require(stats)
> mosaicplot(mytotal1)
>
> It's good, but it only creates rectangles that are stacked on top of
> each other, which is not exactly what I was looking for.

Because that's what you specified. Compare these:
mosaicplot(matrix(c(50, 30, 20, 0), 2, 2))
mosaicplot(matrix(c(0, 50, 20, 30), 2, 2))

> Is there a R package for waffle chart?
> I tried help.search("waffle") and found nothing. Also nothing on Google...

You might also find the R Graph Gallery helpful; you can browse many
different types of plots there, and might find what you are thinking
of.

Sarah

> Thanks!
> Dimitri
>
> On Thu, Jul 21, 2011 at 11:33 AM, Hadley Wickham <hadley at rice.edu> wrote:
>> This is called a squarified pie chart or a waffle chart (if you want
>> to keep the food metaphor going):
>>
>>
>>
>> On Thu, Jul 21, 2011 at 10:29 AM, Dimitri Liakhovitski
>> <dimitri.liakhovitski at gmail.com> wrote:
>>> Hello!
>>> It's a shoot in the dark, but I'll try. If one has a total of 100
>>> (e.g., %), and three components of the total, e.g.,
>>> mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with
>>> 3 sectors representing x, y, and z according to their proportions in
>>> the total.
>>> I am wondering if it's possible to build something very similar, but
>>> not on a circle but in a square - such that the total area of the
>>> square is the sum of the components and the components (x, y, and z)
>>> are represented on a square as shapes with right angles (squares,
>>> rectangles, L-shapes, etc.). I realize there are many possible
>>> positions and shapes - even for 3 components. But I don't really care
>>> where components are located within the square - as long as they are
>>> there.
>>>
>>> Is there a package that could do something like that?

--
Sarah Goslee
http://www.functionaldiversity.org

```