

.. _sphx_glr_gallery_ticks:

.. _ticks_examples:

Ticks
=====



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Setting the behavior of tick auto-placement.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_auto_ticks_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_auto_ticks.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Automatically setting tick positions</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Ticklabels are aligned relative to their associated tick. The alignment &#x27;center&#x27;, &#x27;left&#x27;, or &#x27;right&#x27; can be controlled using the horizontal alignment property::">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_centered_ticklabels_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_centered_ticklabels.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Center labels between ticks</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Vertical colorbars have ticks, tick labels, and labels visible on the y axis, horizontal colorbars on the x axis. The ticks parameter can be used to set the ticks and the format parameter can be used to format the tick labels of the visible colorbar Axes. For further adjustments, the yaxis or xaxis Axes of the colorbar can be retrieved using its ax property.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_colorbar_tick_labelling_demo_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_colorbar_tick_labelling_demo.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Colorbar Tick Labelling</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The matplotlib.ticker module defines many preset tickers, but was primarily designed for extensibility, i.e., to support user customized ticking.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_custom_ticker1_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_custom_ticker1.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Ticker</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Finding good tick values and formatting the ticks for an axis that has date data is often a challenge.  ConciseDateFormatter is meant to improve the strings chosen for the ticklabels, and to minimize the strings used in those tick labels as much as possible.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_date_concise_formatter_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_date_concise_formatter.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Format date ticks using ConciseDateFormatter</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Date Demo Convert">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_date_demo_convert_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_date_demo_convert.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Date Demo Convert</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The `iCalender RFC`_ specifies recurrence rules (rrules), that define date sequences. You can use rrules in Matplotlib to place date ticks.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_date_demo_rrule_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_date_demo_rrule.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Placing date ticks using recurrence rules</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the usage and effect of the various date locators and formatters.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_date_formatters_locators_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_date_formatters_locators.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Date tick locators and formatters</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="When plotting daily data, e.g., financial time series, one often wants to leave out days on which there is no data, for instance weekends, so that the data are plotted at regular intervals without extra spaces for the days with no data. The example shows how to use an &#x27;index formatter&#x27; to achieve the desired plot.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_date_index_formatter_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_date_index_formatter.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom tick formatter for time series</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Matplotlib can handle datetime objects and numpy.datetime64 objects using a unit converter that recognizes these dates and converts them to floating point numbers.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_date_precision_and_epochs_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_date_precision_and_epochs.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Date precision and epochs</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Use a format string to prepend dollar signs on y-axis labels.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_dollar_ticks_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_dollar_ticks.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Dollar ticks</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="matplotlib.ticker.EngFormatter is capable of computing a natural offset for your axis data, and presenting it with a standard SI prefix automatically calculated.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_engformatter_offset_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_engformatter_offset.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">SI prefixed offsets and natural order of magnitudes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Customize the background, labels and ticks of a simple plot.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_fig_axes_customize_simple_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_fig_axes_customize_simple.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Fig Axes Customize Simple</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate how to use major and minor tickers.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_major_minor_demo_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_major_minor_demo.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Major and minor ticks</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Sometimes we want another level of tick labels on an axis, perhaps to indicate a grouping of the ticks.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_multilevel_ticks_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_multilevel_ticks.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multilevel (nested) ticks</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="By default, tick labels are formatted using a ScalarFormatter, which can be configured via ticklabel_format.  This example illustrates some possible configurations:">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_scalarformatter_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_scalarformatter.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">The default tick formatter</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Tick formatters define how the numeric value associated with a tick on an axis is formatted as a string.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_tick-formatters_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_tick-formatters.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Tick formatters</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Tick locators define the position of the ticks.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_tick-locators_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_tick-locators.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Tick locators</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="We can use ytick.labelright, ytick.right, ytick.labelleft, and ytick.left to control where on the axes ticks and their labels appear. These properties can also be set in .matplotlib/matplotlibrc.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_tick_label_right_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_tick_label_right.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Set default y-axis tick labels on the right</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Using Axes.set_xticks causes the tick labels to be set on the currently chosen ticks. However, you may want to allow matplotlib to dynamically choose the number of ticks and their spacing.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_tick_labels_from_values_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_tick_labels_from_values.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Setting tick labels from a list of values</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="tick_params can be used to configure the ticks. top and labeltop control the visibility tick lines and labels at the top x-axis. To move x-axis ticks from bottom to top, we have to activate the top ticks and deactivate the bottom ticks::">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_tick_xlabel_top_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_tick_xlabel_top.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Move x-axis tick labels to the top</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Rotated tick labels">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_ticklabels_rotation_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_ticklabels_rotation.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Rotated tick labels</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="One common cause for unexpected tick behavior is passing a list of strings instead of numbers or datetime objects. This can easily happen without notice when reading in a comma-delimited text file. Matplotlib treats lists of strings as categorical variables (/gallery/lines_bars_and_markers/categorical_variables), and by default puts one tick per category, and plots them in the order in which they are supplied.  If this is not desired, the solution is to convert the strings to a numeric type as in the following examples.">

.. only:: html

  .. image:: /gallery/ticks/images/thumb/sphx_glr_ticks_too_many_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_ticks_ticks_too_many.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Fixing too many ticks</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /gallery/ticks/auto_ticks
   /gallery/ticks/centered_ticklabels
   /gallery/ticks/colorbar_tick_labelling_demo
   /gallery/ticks/custom_ticker1
   /gallery/ticks/date_concise_formatter
   /gallery/ticks/date_demo_convert
   /gallery/ticks/date_demo_rrule
   /gallery/ticks/date_formatters_locators
   /gallery/ticks/date_index_formatter
   /gallery/ticks/date_precision_and_epochs
   /gallery/ticks/dollar_ticks
   /gallery/ticks/engformatter_offset
   /gallery/ticks/fig_axes_customize_simple
   /gallery/ticks/major_minor_demo
   /gallery/ticks/multilevel_ticks
   /gallery/ticks/scalarformatter
   /gallery/ticks/tick-formatters
   /gallery/ticks/tick-locators
   /gallery/ticks/tick_label_right
   /gallery/ticks/tick_labels_from_values
   /gallery/ticks/tick_xlabel_top
   /gallery/ticks/ticklabels_rotation
   /gallery/ticks/ticks_too_many

