|||
Adjusting the spacing of margins and subplots using pyplot.subplots_adjust
.
Note
There is also a tool window to adjust the margins and spacings of displayed
figures interactively. It can be opened via the toolbar or by callingpyplot.subplot_tool
.
import matplotlib.pyplot as pltimport numpy as np# Fixing random state for reproducibilitynp.random.seed(19680801)plt.subplot(211)plt.imshow(np.random.random((100, 100)))plt.subplot(212)plt.imshow(np.random.random((100, 100)))plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)cax = plt.axes([0.85, 0.1, 0.075, 0.8])plt.colorbar(cax=cax)plt.show()
Download Python source code: subplots_adjust.py
Download Jupyter notebook: subplots_adjust.ipynb
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-14 13:20
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社