How to fix matplotlib's subplots when the entire layout can not be filled?
Question:
I would like to plot a DataFrame with say 29 columns, so I use the matplotlib’s "subplots" command using 5×6 layout, (5×6 = 30 > 29)
fig, ax = plt.subplots(5,6)
However, when I plot all of the columns, the last subplot (i.e., row=5, col=6) is empty because there is no data to show there. Is there a way to remove that last subplot?
Answers:
Try this
fig.delaxes(axs[5,6])
plt.show()
I would like to plot a DataFrame with say 29 columns, so I use the matplotlib’s "subplots" command using 5×6 layout, (5×6 = 30 > 29)
fig, ax = plt.subplots(5,6)
However, when I plot all of the columns, the last subplot (i.e., row=5, col=6) is empty because there is no data to show there. Is there a way to remove that last subplot?
Try this
fig.delaxes(axs[5,6])
plt.show()