I'm having some trouble trying to change the figure size when using plt.subplots
. With the following code, I just get the standard size graph with all my subplots bunched in (there's ~100) and obviously just an extra empty figuresize . I've tried using tight_layout
, but to no avail.
def plot(reader):
channels=[]
for i in reader:
channels.append(i)
plt.figure(figsize=(50,100))
fig, ax = plt.subplots(len(channels), sharex=True)
plot=0
for j in reader:
ax[plot].plot(reader["%s" % j])
plot=plot+1
plt.tight_layout()
plt.show()
You can remove your initial
plt.figure()
. When callingplt.subplots()
a new figure is created, so you first call doesn't do anything.The subplots command in the background will call
plt.figure()
for you, and any keywords will be passed along. So just add thefigsize
keyword to thesubplots()
command: