

.. _sphx_glr_gallery_userdemo_demo_gridspec05.py:


===============
Demo Gridspec05
===============





.. image:: /gallery/userdemo/images/sphx_glr_demo_gridspec05_001.png
    :align: center





.. code-block:: python

    import matplotlib.pyplot as plt
    import matplotlib.gridspec as gridspec


    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")
            for tl in ax.get_xticklabels() + ax.get_yticklabels():
                tl.set_visible(False)


    f = plt.figure()

    gs = gridspec.GridSpec(2, 2,
                           width_ratios=[1, 2], height_ratios=[4, 1])

    ax1 = plt.subplot(gs[0])
    ax2 = plt.subplot(gs[1])
    ax3 = plt.subplot(gs[2])
    ax4 = plt.subplot(gs[3])

    make_ticklabels_invisible(f)
    plt.show()

**Total running time of the script:** ( 0 minutes  0.220 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
