.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/images_contours_and_fields/watermark_image.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. 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_images_contours_and_fields_watermark_image.py: =============== Watermark image =============== Overlay an image on a plot by moving it to the front (``zorder=3``) and making it semi-transparent (``alpha=0.7``). .. GENERATED FROM PYTHON SOURCE LINES 9-31 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import matplotlib.cbook as cbook import matplotlib.image as image with cbook.get_sample_data('logo2.png') as file: im = image.imread(file) fig, ax = plt.subplots() np.random.seed(19680801) x = np.arange(30) y = x + np.random.randn(30) ax.bar(x, y, color='#6bbc6b') ax.grid() fig.figimage(im, 25, 25, zorder=3, alpha=.7) plt.show() .. image-sg:: /gallery/images_contours_and_fields/images/sphx_glr_watermark_image_001.png :alt: watermark image :srcset: /gallery/images_contours_and_fields/images/sphx_glr_watermark_image_001.png, /gallery/images_contours_and_fields/images/sphx_glr_watermark_image_001_2_00x.png 2.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 32-40 .. admonition:: References The use of the following functions, methods, classes and modules is shown in this example: - `matplotlib.image` - `matplotlib.image.imread` / `matplotlib.pyplot.imread` - `matplotlib.figure.Figure.figimage` .. _sphx_glr_download_gallery_images_contours_and_fields_watermark_image.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: watermark_image.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: watermark_image.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_