1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
"""
=============================
Subplots spacings and margins
=============================
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 calling
`.pyplot.subplot_tool`.
.. redirect-from:: /gallery/subplots_axes_and_figures/subplot_toolbar
"""
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.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()
# %%
# .. tags::
#
# component: subplot
# plot-type: imshow
# level: beginner
|