{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Watermark image\n\nOverlay an image on a plot by moving it to the front (``zorder=3``) and making it\nsemi-transparent (``alpha=0.7``).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\nimport numpy as np\n\nimport matplotlib.cbook as cbook\nimport matplotlib.image as image\n\nwith cbook.get_sample_data('logo2.png') as file:\n im = image.imread(file)\n\nfig, ax = plt.subplots()\n\nnp.random.seed(19680801)\nx = np.arange(30)\ny = x + np.random.randn(30)\nax.bar(x, y, color='#6bbc6b')\nax.grid()\n\nfig.figimage(im, 25, 25, zorder=3, alpha=.7)\n\nplt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
".. admonition:: References\n\n The use of the following functions, methods, classes and modules is shown\n in this example:\n\n - `matplotlib.image`\n - `matplotlib.image.imread` / `matplotlib.pyplot.imread`\n - `matplotlib.figure.Figure.figimage`\n\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}