18
$\begingroup$

I have a data like this:

> table(A,B,C)
, , C = FALSE

       B
A       FALSE TRUE
  FALSE   177   42
  TRUE      6    8

, , C = TRUE

       B
A       FALSE TRUE
  FALSE     5   31
  TRUE      4   10

How can I plot this on a single graph, possibly without imposing any hierarchy?

$\endgroup$

2 Answers 2

15
$\begingroup$

I would try some kind of 3D heatmap, mosaic plot or a sieve plot (available in the vcd package). Isn't the base mosaicplot() function working with three-way table? (at least mosaic3d() in the vcdExtra package should work, see e.g. http://datavis.ca/R/)

Here's an example (including a conditional plot):

A <- sample(c(T,F), 100, replace=T)
B <- sample(c(T,F), 100, replace=T)
C <- sample(c(T,F), 100, replace=T)
tab <- table(A,B,C)
library(vcd)
sieve(tab, shade=TRUE)
cotabplot(tab)
library(vcdExtra)
mosaic3d(tab, type="expected", box=TRUE)

alt text

alt text

alt text

Actually, the rendering of mosaic3d() rely on the rgl package, so it is hard to give a pretty picture of the result.

$\endgroup$
1
  • 1
    $\begingroup$ +1 this is neat, I'd forgotten about the vcdExtra package. $\endgroup$
    – ars
    Nov 4, 2010 at 20:01
11
$\begingroup$

I recently came across a paper by Hadley Wickham and I was reminded of this question (I must spend too much time on the site!)

Wickham, Hadley and Heike Hofmann. 2011. Product plots. IEEE Transactions on Visualization and Computer Graphics (Proc. Infovis `11). Pre-print PDF

Abstract

We propose a new framework for visualising tables of counts, proportions and probabilities. We call our framework product plots, alluding to the computation of area as a product of height and width, and the statistical concept of generating a joint distribution from the product of conditional and marginal distributions. The framework, with extensions, is sufficient to encompass over 20 visualisations previously described in fields of statistical graphics and infovis, including bar charts, mosaic plots, treemaps, equal area plots and fluctuation diagrams.

I know it is typical to try to give greater explanation, but I don't think I can do any better job than the abstract and posting some pictures! The novel examples they present in the right most images (I believe) meet your requirements without imposing a hierarchy.

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy