[R] Stacked squares plots
jim at bitwrit.com.au
Tue Nov 4 10:05:11 CET 2014
On Tue, 4 Nov 2014 01:54:45 AM Osman Al-Radi wrote:
> Dear R-help users,
> I would like to produce a plot of ordered stacked coloured square
> square would represent a level of a categorical variable CAT (aprox.
> levels), the size of the square would represent the frequency FREQ
> of that level, the color would represent a proportion of failure
> to 1) and the squares would be organized by size from bottom left
> It would be an extra bonus if one could produce one such plot for
> of a higher order categorical variable GROUP with say 6 levels. All in
> plot similar to panels in lattice but without the gaps between panels.
> Any ideas. I played around with mosaicplot and rectangle but
> satisfactory result.
> example data
> GROUP CAT FREQ FAILURE
> 1 a 100 0.05
> 1 b 20 0.1
> And so forth.
The function color2D.matplot (plotrix) has a Hinton diagram option
that might do what you want. The squares will be distributed on a plot
in the same positions as the matrix that is passed as the "x"
argument. The sizes of the squares will be proportional to "x" and the
colors can be anything you pass as "cellcolors". Let me know if you
have trouble working it out.
More information about the R-help