.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "recipes/axes/plot_numerical_axis_tick_format.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_recipes_axes_plot_numerical_axis_tick_format.py: Numerical axis formatting and intervals --------------------------- Numerical axes can be formatted with the ``tick_interval`` and ``tick_format`` arguments for ``axis``. - ``axis_type`` should be set to ``number``, ``percent``, or ``currency``. - Intervals should be of the same data type as the series on the axis. In most cases this will be a ``float`` or and ``int``. - Tick formats should be specified as a numerical D3 format (`Docs `_). This is the formatting system Plotly uses and is very similar to the formatting options available in python f-strings. - In the example below for the ``y1_axis``: - A currency format (``$,0.2f``) is used. This adds the USD currency prefix, thousands separator, decimal separator, and 2 fixed decimal places to the ticks on the axis. - The tick interval is set to 25,000 and thus each tick is separated by that amount - In the example below for the ``y2_axis``: - A percent format (``0.1%``) is used. Note that the data values are automatically multipled by 100, with 1 fixed decimal place and a % symbol as a suffix. - The tick interval is set to 0.05, to denote 5% steps on the axis .. GENERATED FROM PYTHON SOURCE LINES 19-68 .. raw:: html


.. code-block:: Python import pandas as pd from visualization_toolkit.helpers.plotly import chart, axis, series fig = chart( pdf, x_axis=axis(column_name="fiscal_qy", label="Fiscal Quarter"), y1_axis=axis( label="Sales", axis_type="currency", tick_format="$,.2f", tick_interval=25000, axis_max=250000, ), y2_axis=axis( label="Growth Rate", axis_type="percent", tick_format=".1%", tick_interval=0.05, axis_max=0.2, axis_min=0.2, ), chart_series=[ series( column_name="ucan", label="UCAN", color="light-blue", mode="bar", is_stacked=True, ), series( column_name="china", label="China", color="light-grey", mode="bar", is_stacked=True, ), series( column_name="yy", label="Y/Y Growth Rate", color="black", location="y2", shape="dash", ), ], ) fig .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.025 seconds) .. _sphx_glr_download_recipes_axes_plot_numerical_axis_tick_format.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_numerical_axis_tick_format.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_numerical_axis_tick_format.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_numerical_axis_tick_format.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_