Clear presentation, recursive programming, and art are all irresistible

Here is a little mosaic plot of passengers surviving the Titanic sinking. The mosaic plot shows many things clearly, for instance, that there were more men than women passengers, which can be seen by comparing the sizes of the left and right hand columns.

The green areas are survivors, and the red areas represent people who died. Evidently, first class men survived much better than other men, but first and second class women almost all survived. Most third class passengers died, whether men or women. The plot doesn’t show the crew survival rates.

It’s more versatile than that!

My code can also draw a Mondrian-style mosaic from the same data.

Ideas

Playing with pretty mosaics from random data helped find a bug: random data is always good at that! I trim rectangles to create the white spaces, but if you trim a very small rectangle, you can end up with a rectangle of negative area, which is then rendered as a rectangle in the wrong place. That’s fixed now.

In fact, trimming isn’t the best thing to do, since it means the rectangle areas aren’t quite proportional to the data they represent.

Read an excellent history of mosaic plots at “A Brief History of the Mosaic Display,” Michael Friendly, 2001.

Harold Thimbleby, 2011