Closed
Description
Bug report
Bug summary
Repeatedly saving a figure created using constrained_layout=True
and using GridSpec
, grids in the figure collapses after nth time. From 0 to 90 figure is generated as expected. From 91 grids inside the figure collapses. Sample images shown here.
Code for reproduction
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.colors as mcolors
import matplotlib._layoutbox as layoutbox
plt.style.use('ggplot')
def gridspec_bug(file):
fig = plt.figure(figsize=(2,5), constrained_layout=True)
gs = gridspec.GridSpec(5, 1, figure=fig, height_ratios=[1/20, 6/20, 6/20, 4/20, 3/20])
ax1 = fig.add_subplot(gs[0])
ax2 = fig.add_subplot(gs[1])
ax3 = fig.add_subplot(gs[2])
ax4 = fig.add_subplot(gs[3], sharex=ax3)
ax5 = fig.add_subplot(gs[4], sharex=ax3)
fig.text(0.5, 0.5, file, fontsize=25, color='black', ha='center', va='center')
fig.savefig(file, format='png')
plt.close(fig)
if __name__ == '__main__':
for i in range(0, 110):
file_name = f'{i}.png'
gridspec_bug(file_name)
print(f'Done {i}')
Matplotlib version
- Operating system:
Windows 10
- Matplotlib version:
2.2.2
- Matplotlib backend (
print(matplotlib.get_backend())
):agg
- Python version:
3.6.6 |Anaconda custom (64-bit)| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)]
- Jupyter version (if applicable): NA
- Other libraries: NA
Metadata
Metadata
Assignees
Labels
No labels