.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_03_view_with_annotations.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_plot_03_view_with_annotations.py: View With Annotations ===================== Matplotview's views are also regular matplotlib `Axes `_, meaning they support regular plotting on top of their viewing capabilities, allowing for annotations, as shown below. .. GENERATED FROM PYTHON SOURCE LINES 9-48 .. image-sg:: /examples/images/sphx_glr_plot_03_view_with_annotations_001.png :alt: plot 03 view with annotations :srcset: /examples/images/sphx_glr_plot_03_view_with_annotations_001.png :class: sphx-glr-single-img .. code-block:: default :lineno-start: 10 # All the same as from the prior inset axes example... from matplotlib import cbook import matplotlib.pyplot as plt import numpy as np from matplotview import inset_zoom_axes def get_demo_image(): z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True) return z, (-3, 4, -4, 3) fig, ax = plt.subplots() Z, extent = get_demo_image() Z2 = np.zeros((150, 150)) ny, nx = Z.shape Z2[30:30 + ny, 30:30 + nx] = Z ax.imshow(Z2, extent=extent, interpolation='nearest', origin="lower") axins = inset_zoom_axes(ax, [0.5, 0.5, 0.47, 0.47]) x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9 axins.set_xlim(x1, x2) axins.set_ylim(y1, y2) # We'll annotate the 'interesting' spot in the view.... axins.annotate( "Interesting Feature", (-1.3, -2.25), (0.1, 0.1), textcoords="axes fraction", arrowprops=dict(arrowstyle="->") ) axins.set_xticklabels([]) axins.set_yticklabels([]) ax.indicate_inset_zoom(axins, edgecolor="black") fig.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.200 seconds) .. _sphx_glr_download_examples_plot_03_view_with_annotations.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_view_with_annotations.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_view_with_annotations.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_