.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_gallery_axes_grid1_simple_axes_divider1.py:
=====================
Simple Axes Divider 1
=====================
.. code-block:: default
from mpl_toolkits.axes_grid1 import Size, Divider
import matplotlib.pyplot as plt
Fixed axes sizes; fixed paddings.
.. code-block:: default
fig = plt.figure(figsize=(6, 6))
# Sizes are in inches.
horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), Size.Fixed(.5)]
vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)]
rect = (0.1, 0.1, 0.8, 0.8)
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
divider = Divider(fig, rect, horiz, vert, aspect=False)
# The rect parameter will actually be ignored and overridden by axes_locator.
ax1 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=0))
ax2 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=2))
ax3 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, ny=2))
ax4 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, nx1=4, ny=0))
for ax in fig.axes:
ax.tick_params(labelbottom=False, labelleft=False)
.. image:: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_001.png
:alt: simple axes divider1
:class: sphx-glr-single-img
Axes sizes that scale with the figure size; fixed paddings.
.. code-block:: default
fig = plt.figure(figsize=(6, 6))
horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), Size.Scaled(.5)]
vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]
rect = (0.1, 0.1, 0.8, 0.8)
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
divider = Divider(fig, rect, horiz, vert, aspect=False)
# The rect parameter will actually be ignored and overridden by axes_locator.
ax1 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=0))
ax2 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=2))
ax3 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, ny=2))
ax4 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, nx1=4, ny=0))
for ax in fig.axes:
ax.tick_params(labelbottom=False, labelleft=False)
plt.show()
.. image:: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_002.png
:alt: simple axes divider1
:class: sphx-glr-single-img
.. _sphx_glr_download_gallery_axes_grid1_simple_axes_divider1.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: simple_axes_divider1.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: simple_axes_divider1.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
Keywords: matplotlib code example, codex, python plot, pyplot
`Gallery generated by Sphinx-Gallery
`_