From: Chris B. <bea...@ha...> - 2013-08-31 15:21:45
|
Pandas has some nice tools to make faceted plots -- small multiples of plots where data is grouped by category ( http://pandas.pydata.org/pandas-docs/stable/rplot.html). However, I think there would be value in having this functionality built into matplotlib. Mainly: 1. Not every dataset lives in a dataframe 2. The pandas library mimics the ggplot interface, and some people would prefer an interface closer to matplotlib 3. Properly implemented, I think a matplotlib facet system would enable a wider variety of faceted plots than the pandas tools. I've taken a stab at this, and came up with an interface that I think has potential. This currently exists as a separate repository at https://github.com/ChrisBeaumont/mplfacet, and an example notebook at http://bit.ly/17u1JzP There two basic ways to use a facet object: Facet(key, data).method() will group one or more data arrays by key, and build a subplot for each group by calling method (which is any axes plot method). Alternatively, for item in Facet(key, data): x, y = item.data item.axes.scatter(x, y) sets up the subplots and groups the data for you, but gives you more freedom to populate each subplot however you like. Is there interest in building this into matplotlib? If so, I would like to polish it up and submit a PR. Cheers, Chris |