.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/axis_and_tick/99.tick_labels_inside_triangle.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_99.tick_labels_inside_triangle.py: =========================== Tick labels inside triangle =========================== You can put tick labels inside triangle by setting ``labelrotation=manual`` and then specifying appropriate ``Text`` properties as follows. .. note:: This works also in interactive modes. This is achieved by overriding ``Axis._copy_tick_props`` also to update the *y* coordinate. .. GENERATED FROM PYTHON SOURCE LINES 14-48 .. image-sg:: /gallery/axis_and_tick/images/sphx_glr_99.tick_labels_inside_triangle_001.svg :alt: 99.tick labels inside triangle :srcset: /gallery/axis_and_tick/images/sphx_glr_99.tick_labels_inside_triangle_001.svg :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import mpltern # noqa: F401 fig = plt.figure() ax = fig.add_subplot(projection='ternary') ax.set_tlabel('Top') ax.set_llabel('Left') ax.set_rlabel('Right') ax.grid() ax.tick_params(tick1On=False, tick2On=False) # By setting ``labelrotation='manual'``, automatic rotation and alignment for # tick labels are prohibited. ax.taxis.set_tick_params(labelrotation=('manual', 0.0)) ax.laxis.set_tick_params(labelrotation=('manual', -60.0)) ax.raxis.set_tick_params(labelrotation=('manual', 60.0)) # Then, ``Text`` properties you like can be passed directly by ``update``. kwargs = {'y': 0.5, 'ha': 'center', 'va': 'center', 'rotation_mode': 'anchor'} tkwargs = {'transform': ax.get_taxis_transform()} lkwargs = {'transform': ax.get_laxis_transform()} rkwargs = {'transform': ax.get_raxis_transform()} tkwargs.update(kwargs) lkwargs.update(kwargs) rkwargs.update(kwargs) [text.update(tkwargs) for text in ax.taxis.get_ticklabels()] [text.update(lkwargs) for text in ax.laxis.get_ticklabels()] [text.update(rkwargs) for text in ax.raxis.get_ticklabels()] plt.show() .. _sphx_glr_download_gallery_axis_and_tick_99.tick_labels_inside_triangle.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 99.tick_labels_inside_triangle.ipynb <99.tick_labels_inside_triangle.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 99.tick_labels_inside_triangle.py <99.tick_labels_inside_triangle.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_