Search code examples
pythonplotfacet-wrap

Wrap multiple plots together in a single image


I am trying to wrap numerous plots together, as they are closely related (showing density using 1 continuous and 1 categorical variable, broken down by day of the week, where each day is a different plot). In R, I can either use grid.arrange() from gridExtra or facet_wrap to wrap visualizations together to return to the user as 1 variable and image containing all plots. It looks like this:

All 7 of these plots are combined into 1 image, using <code>grid.arrange()</code>

How do I do this in Python?


Solution

  • Yes, this can be done using matplotlib subplots. See this example.

    The layout of the visualization can be initialized with the desired number of rows and columns. Each cell will contain a different subplot.

    fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(7, 7))