How to make a mosaic plot in R

February 16, 2010
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

Mosaic plots (aka treemaps) are a great way to visualize hierarchical data. A collection of rectangles represents all the elements to be visualized (customers, news items, blog posts), with the size and color of the rectangles coding attribute. But what makes this chart unique is the arrangement of the elements: where there is hierarchy (customer segments, news topics, post categories) those elements are collected and labelled together, perhaps even with subcategories. It's easier to show than explain: you might have seen this mosaic plot of stories in Google News before, where the stories are arranged by topic area (news, sports, etc.) and sized by the number of mentions. You can create your own mosaic plot yourself in R, too: FlowingData explains how, using their own blog posts (arranged by category) as data.

Mosaic chart 

Click the link below for the simple five-step process, using the map.market function from the portfolio package (with some final touch-up in Adobe Illustrator).

FlowingData: An Easy Way to Make a Treemap

To leave a comment for the author, please follow the link and comment on his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.