How to make a mosaic plot in R
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.
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
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.