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

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

.. _sphx_glr_gallery_axes_grid1_simple_axisline4.py:


================
Simple Axisline4
================





.. image:: /gallery/axes_grid1/images/sphx_glr_simple_axisline4_001.png
    :class: sphx-glr-single-img





.. code-block:: python

    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import host_subplot
    import numpy as np

    ax = host_subplot(111)
    xx = np.arange(0, 2*np.pi, 0.01)
    ax.plot(xx, np.sin(xx))

    ax2 = ax.twin()  # ax2 is responsible for "top" axis and "right" axis
    ax2.set_xticks([0., .5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])
    ax2.set_xticklabels(["$0$", r"$\frac{1}{2}\pi$",
                         r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"])

    ax2.axis["right"].major_ticklabels.set_visible(False)
    ax2.axis["top"].major_ticklabels.set_visible(True)

    plt.draw()
    plt.show()


.. _sphx_glr_download_gallery_axes_grid1_simple_axisline4.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: simple_axisline4.ipynb <simple_axisline4.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>`_
