How to make a mosaic plot in R

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 their blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)