Reputation: 308
I'm trying to make a row with 5 square graphs. I'm currently doing this:
import matplotlib.pyplot as plt
fig, axarr = plt.subplots(1, 5)
#code to populate the graphs here
plt.show()
However, this gives me 5 graphs that are very skinny and tall rectangles. If i size them down into squares with the format subplots tool, then the image generated is mostly white space. How can I generate these graphs as squares in one row, without all the white space?
Upvotes: 0
Views: 1102
Reputation: 622
You need to set the figure size:
plt.rcParams['figure.figsize'] = (20,5) # width, height
plt.subplot( 151 ) # a fig with 1 row, 5 columns, 1st graph
plt.plot( x,y )
plt.subplot( 152 ) # 2nd graph
plt.plot( ... )
# and similarly for the next ones
plt.show()
Upvotes: -1
Reputation: 6053
Simply change the shape of your figure.
import matplotlib.pyplot as plt
fig, axarr = plt.subplots(1, 5, figsize=(5, 1))
#code to populate the graphs here
plt.subplots_adjust(hspace=0.0)
plt.show()
Upvotes: 2