.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/plot_angle.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__auto_examples_plot_angle.py: Plot Angle Example ================== :func:`sysplot.plot_angle` draws a labeled arc between two vectors sharing a common center, annotating the angle between them. The result is an arc with a :math:`\theta` label indicating the enclosed angle. This example shows: - Basic usage with default settings - Changing text position ("inside", "outside", "edge") - Using different units for the arc size - Accessing the computed angle .. GENERATED FROM PYTHON SOURCE LINES 15-76 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_auto_examples/images/sphx_glr_plot_angle_001.png :alt: Basic plot_angle :srcset: /_auto_examples/images/sphx_glr_plot_angle_001.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_plot_angle_002.png :alt: Text position: inside, Text position: outside, Text position: edge, Text position: legend :srcset: /_auto_examples/images/sphx_glr_plot_angle_002.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_plot_angle_003.png :alt: plot angle :srcset: /_auto_examples/images/sphx_glr_plot_angle_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none Measured angle (basic): 51.16° | .. code-block:: Python import matplotlib.pyplot as plt import sysplot as ssp ssp.apply_config() # -------------------------- # Define points # -------------------------- center = (0.0, 0.0) p1 = (1.0, 0.0) p2 = (0.8, 1.0) # -------------------------- # Basic usage # -------------------------- fig, ax = plt.subplots(figsize=(5, 5)) ax.plot(*zip(center, p1), label="Vector 1") ax.plot(*zip(center, p2), label="Vector 2") angle_deg = ssp.plot_angle(center, p1, p2, text=r"$\theta$", ax=ax) ax.set_title("Basic plot_angle") print(f"Measured angle (basic): {angle_deg:.2f}°") plt.show() # -------------------------- # Text position variations # -------------------------- fig, axs = plt.subplots(1, 4, figsize=(20, 5)) positions = ["inside", "outside", "edge", "legend"] colors = ["green", "red", "blue", "orange"] for ax, pos, color in zip(axs, positions, colors): ax.plot(*zip(center, p1), label="Vector 1") ax.plot(*zip(center, p2), label="Vector 2") ssp.plot_angle( center, p1, p2, text=pos.capitalize(), textposition=pos, size=300, ax=ax, color=color, ) ax.set_title(f"Text position: {pos}") ax.legend() plt.show() # -------------------------- # Different size units # -------------------------- fig, axs = plt.subplots(1, 2, figsize=(12, 5)) units = ["axes width", "axes height"] colors = ["orange", "purple"] for ax, unit, color in zip(axs, units, colors): ax.plot(*zip(center, p1), label="Vector 1") ax.plot(*zip(center, p2), label="Vector 2") ssp.plot_angle(center, p1, p2, text=unit, unit=unit, size=0.5, ax=ax, color=color) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.322 seconds) .. _sphx_glr_download__auto_examples_plot_angle.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_angle.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_angle.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_angle.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_