How it works...

Here is the explanation for the preceding code:

This is the first plot:

  • g = sns.FacetGrid(snacks_sales, col="Promotion", row="weekend", height=3) creates the grid:
    • snacks_sales is the input DataFrame.
    • col="Promotion" specifies Promotion as the column variable.
    • row="weekend" specifies weekend as the row variable.
    • height=3 specifies the height of each of the plots in the grid.
    • A default aspect ratio of 1 is used, which means width is same as height.
  • g = g.map(plt.hist, "Cookies", bins=10, color='m') plots a histogram on all plots of the grid:
    • bins=10, specifies the number of bins in the histogram.
    • color='m', specifies to use magenta as the color.

This is the second plot:

  • g = sns.FacetGrid(snacks_sales, col="Promotion", ...

Get Matplotlib 3.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.