Home > Back-end >  Matplotlib subplots are all the same size ... how to set them up so subplots scale including the xti
Matplotlib subplots are all the same size ... how to set them up so subplots scale including the xti

Time:01-22

Here's some example code:

from matplotlib import pyplot as plt

plt.subplot(221)
plt.bar(range(3),[34, 37, 16]) # some random data
plt.xticks(range(3),"Jan,Feb,Mar".split(','))

plt.subplot(222)
plt.bar(range(3),[34, 37, 16])
plt.xticks(range(3),"January,February,March".split(','), rotation=90)

plt.subplot(223)
plt.bar(range(3),[34, 37, 16])
plt.xticks(range(3),"Jan,Feb,Mar".split(','))

plt.tight_layout()
plt.show()

Which results in this, with all the plot heights equal size:

enter image description here

But I'd like it to look like this, with the entire 'subfigure' equal size:

enter image description here

CodePudding user response:

Using subfigures (enter image description here

  •  Tags:  
  • Related