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?

Asked By: motam79

||

Answers:

Try this

fig.delaxes(axs[5,6]) 
plt.show()
Answered By: A.Kot
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.