19
pandas: powerful Python data analysis toolkit, Release 0.18.1
tips_data = pd.read_csv('tips.csv')
from the directory where you downloaded the file.
We import the rplot API:
In [185]: import pandas.tools.rplot as rplot
23.7.1 Examples
RPlot was an APIfor producing Trellis plots. These plots allow you to arrange data in a rectangulargrid by values of
certain attributes. In the example below, data from the tips data set is arranged by the attributes ‘sex’ and ‘smoker’.
Since both of those attributes can take on one of two values, the resulting grid has two columns and two rows. A
histogramis displayed for each cell of the grid.
In [186]: plt.figure()
Out[186]: <matplotlib.figure.Figure at t 0x12c8d9ad0>
In [187]: plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
In [188]: plot.add(rplot.TrellisGrid(['sex', 'smoker']))
In [189]: plot.add(rplot.GeomHistogram())
In [190]: plot.render(plt.gcf())
Out[190]: <matplotlib.figure.Figure at t 0x12c8d9ad0>
23.7. Trellis plotting interface
821