

.. _sphx_glr_gallery_units_radian_demo.py:


============
Radian ticks
============

Plot with radians from the basic_units mockup example package.


This example shows how the unit class can determine the tick locating,
formatting and axis labeling.

.. only:: builder_html

   This example requires :download:`basic_units.py <basic_units.py>`




.. image:: /gallery/units/images/sphx_glr_radian_demo_001.png
    :align: center





.. code-block:: python

    import numpy as np
    from basic_units import radians, degrees, cos
    from matplotlib.pyplot import figure, show

    x = [val*radians for val in np.arange(0, 15, 0.01)]

    fig = figure()
    fig.subplots_adjust(hspace=0.3)

    ax = fig.add_subplot(211)
    line1, = ax.plot(x, cos(x), xunits=radians)

    ax = fig.add_subplot(212)
    line2, = ax.plot(x, cos(x), xunits=degrees)

    show()

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



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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