.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/navchart/plot_customized_navchart.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_examples_navchart_plot_customized_navchart.py: Customized Navigation Chart =========================== A customized navigation chart. In this example, we show how to customize a navigation chart by increasing the number of axis ticks and by annotating one of the datapoints. Adjusting the number of axis ticks can improve a reader's ability to discern between two similar values, while annotations can be useful to draw attention to certain points and/or provide some additional context. Instead of trying to expose all possible customization options as arguments to :py:func:`p3analysis.plot.navchart`, the function returns a :py:class:`p3analysis.plot.NavChart` object that provides direct access to library internals. When using the :py:mod:`matplotlib` backend it is possible to access the :py:class:`matplotlib.axes.Axes` that were used and subsequently call any number of :py:mod:`matplotlib` functions. In our example, we can use :py:meth:`matplotlib.axes.Axes.set_xticks` and :py:meth:`matplotlib.axes.Axes.set_yticks` to control the ticks, and can use :py:meth:`matplotlib.axes.Axes.annotate` for annotations. .. NOTE:: :py:mod:`matplotlib` is currently the only backend supported by the P3 Analysis Library, but this is subject to change. .. TIP:: If you have any trouble customizing a navigation chart, or the :py:class:`~p3analysis.plot.backend.NavChart` object does not provide access to the internals you are looking for, then please `open an issue `_. .. GENERATED FROM PYTHON SOURCE LINES 36-62 .. image-sg:: /examples/navchart/images/sphx_glr_plot_customized_navchart_001.png :alt: plot customized navchart :srcset: /examples/navchart/images/sphx_glr_plot_customized_navchart_001.png :class: sphx-glr-single-img .. code-block:: Python # Initialize synthetic data # (not shown, but available in script download) # Read performance portability and code divergence data into pandas DataFrame pp = pd.DataFrame(pp_data) cd = pd.DataFrame(cd_data) # Generate a navigation chart with custom style options legend = p3analysis.plot.Legend(loc="center left", bbox_to_anchor=(1.0, 0.5)) astyle = p3analysis.plot.ApplicationStyle(markers=["x", "*", "s", "o", "P"]) navchart = p3analysis.plot.navchart(pp, cd, size=(5, 5), legend=legend, style=astyle) # Further customize the navigation chart using matplotlib # In this example, we add a label and adjust the ticks ax = navchart.get_axes() ax.annotate( "Balances performance and code re-use.", xy=(0.7, 0.7), xytext=(0.2, 0.55), arrowprops=dict(facecolor='black', shrink=0.05), ) ax.set_xticks([x * 0.1 for x in range(0, 11)]) ax.set_yticks([y * 0.1 for y in range(0, 11)]) navchart.save("customized-navchart.png") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.204 seconds) .. _sphx_glr_download_examples_navchart_plot_customized_navchart.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_customized_navchart.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_customized_navchart.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_customized_navchart.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_