Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing fewer plots than specified in matplotlib subplots

fig, ax = plt.subplots(3, 3, sharex='col', squeeze=False, figsize=(20, 10))

I want to plot 7 subplots and am using the command above. However it creates 9 plots (including 2 empty ones). How can I make sure that only 7 plots get drawn?

like image 305
user308827 Avatar asked Dec 25 '16 00:12

user308827


1 Answers

import matplotlib.pyplot as plt

fig, axs  = plt.subplots(3,3)
fig.delaxes(axs[-1, -1])
fig.delaxes(axs[-1, -2])

plt.show()

enter image description here

like image 151
Serenity Avatar answered Sep 28 '22 00:09

Serenity