Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a data like this:

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

  FALSE   177   42
  TRUE      6    8

, , C = TRUE

  FALSE     5   31
  TRUE      4   10

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

share|improve this question
up vote 15 down vote accepted

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.

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)
sieve(tab, shade=TRUE)
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.

share|improve this answer
+1 this is neat, I'd forgotten about the vcdExtra package. – ars Nov 4 '10 at 20:01
Very nice list chl - thank you! – Tal Galili Nov 4 '10 at 23:40

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


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

share|improve this answer
(+1) Nice finding! – chl Jan 10 '12 at 20:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.