'Delete a subplot
I'm trying to figure out a way of deleting (dynamically) subplots in matplotlib. I see they have a remove method, but I get the error
NotImplementedError: cannot remove artist
I'm surprised that I can't find this anywhere. Does anyone know how to do this?
from matplotlib import pyplot as plt
fig, axs = plt.subplots(1,3)
axs[0].plot([1,2],[3,4])
axs[2].plot([0,1],[2,3])
plt.draw()
plt.tight_layout()
Solution 1:[1]
ax.set_visible(False)
will suffice in most cases.
Solution 2:[2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | naught101 |
| Solution 2 | stansy |

