.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_gallery_userdemo_demo_gridspec01.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_userdemo_demo_gridspec01.py:


===============
Demo Gridspec01
===============





.. image:: /gallery/userdemo/images/sphx_glr_demo_gridspec01_000.png
    :class: sphx-glr-single-img





.. code-block:: python

    import matplotlib.pyplot as plt


    def make_ticklabels_invisible(fig):
        for i, ax in enumerate(fig.axes):
            ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
            ax.tick_params(labelbottom=False, labelleft=False)


    fig = plt.figure(0)
    ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3)
    ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)
    ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
    ax4 = plt.subplot2grid((3, 3), (2, 0))
    ax5 = plt.subplot2grid((3, 3), (2, 1))

    fig.suptitle("subplot2grid")
    make_ticklabels_invisible(fig)

    plt.show()


.. _sphx_glr_download_gallery_userdemo_demo_gridspec01.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download

     :download:`Download Python source code: demo_gridspec01.py <demo_gridspec01.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: demo_gridspec01.ipynb <demo_gridspec01.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
