.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/axis_and_tick/20.tick-formatters.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_gallery_axis_and_tick_20.tick-formatters.py: =============== Tick formatters =============== .. |PercentFormatter| replace:: ``PercentFormatter`` .. _PercentFormatter: https://matplotlib.org/stable/api/ticker_api.html#matplotlib.ticker.PercentFormatter `Tick formatters can be given in the same way as Matplotlib `__. Among available formatters, |PercentFormatter|_ may be particularly useful for ternary plots. .. GENERATED FROM PYTHON SOURCE LINES 14-37 .. image-sg:: /gallery/axis_and_tick/images/sphx_glr_20.tick-formatters_001.svg :alt: 20.tick formatters :srcset: /gallery/axis_and_tick/images/sphx_glr_20.tick-formatters_001.svg :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import PercentFormatter import mpltern ternary_sum = 100.0 ax = plt.subplot(projection="ternary", ternary_sum=ternary_sum) np.random.seed(19680801) t, l, r = ternary_sum * np.random.dirichlet(alpha=(2.0, 4.0, 8.0), size=128).T ax.scatter(t, l, r, s=64.0, c="none", edgecolors="C0") ax.set_tlabel("$x_1$") ax.set_llabel("$x_2$") ax.set_rlabel("$x_3$") ax.taxis.set_major_formatter(PercentFormatter()) ax.laxis.set_major_formatter(PercentFormatter()) ax.raxis.set_major_formatter(PercentFormatter()) plt.show() .. _sphx_glr_download_gallery_axis_and_tick_20.tick-formatters.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 20.tick-formatters.ipynb <20.tick-formatters.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 20.tick-formatters.py <20.tick-formatters.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_