Skip to content Skip to sidebar Skip to footer

How Could I Arrange Multiple Pyplot Figures In A Kind Of Layout?

I created a software to do signal analyses. There are multiple functions, and each finally display a complex figure containing labels, plot, axhspan, axvspan etc... Usually, these

Solution 1:

You may combine several plots with matplotlib.pyplot.subplot. For more control on the layout, check out the GridSpec.

Edit: As requested, a short example from the linked tutorial:

A gridspec instance provides array-like (2d or 1d) indexing that returns the SubplotSpec instance. For, SubplotSpec that spans multiple cells, use slice.

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
gs = gridspec.GridSpec(3, 3)
ax1 = plt.subplot(gs[0, :])
ax2 = plt.subplot(gs[1,:-1])
ax3 = plt.subplot(gs[1:, -1])
ax4 = plt.subplot(gs[-1,0])
ax5 = plt.subplot(gs[-1,-2])

enter image description here

Post a Comment for "How Could I Arrange Multiple Pyplot Figures In A Kind Of Layout?"