8000 Update watermark example · matplotlib/matplotlib@c08d4dd · GitHub
[go: up one dir, main page]

Skip to content

Commit c08d4dd

Browse files
committed
Update watermark example
Note: this replaces mpl-data/sample_data/logo2.png with the current logo. I think that's ok and we do not guarantee content stability of that data (internally, it's only used for the watermark example). But we could also add it as logo3.png at the cost of having 22kB more data.
1 parent b86ebba commit c08d4dd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

galleries/examples/images_contours_and_fields/watermark_image.py

Lines changed: 11 additions & 3 deletions
< 91AB td data-grid-cell-id="diff-0058fcb021a8ebd9293d0f0d65c18eddc5c11e265915cd19ec7c685c38acb3d7-20-24-1" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Watermark image
44
===============
55
6-
Using a PNG file as a watermark.
6+
Overlay an image on a plot by moving it to the front (``zorder=3``) and making it
7+
semi-transparent (``alpha=0.7``).
78
"""
89

910
import matplotlib.pyplot as plt
@@ -17,9 +18,16 @@
1718

1819
fig, ax = plt.subplots()
1920

20-
ax.plot(np.sin(10 * np.linspace(0, 1)), '-o', ms=20, alpha=0.7, mfc='orange')
21+
np.random.seed(19680801)
22+
x = np.arange(30)
23+
y = np.sin(x) + x + np.random.randn(30)
+
ax.bar(x, y, color='#6bbc6b')
2125
ax.grid()
22-
fig.figimage(im, 10, 10, zorder=3, alpha=.5)
26+
27+
image_size = (542, 130)
28+
nx, ny = fig.get_size_inches() * fig.dpi
29+
30+
fig.figimage(im, (nx - image_size[0]) / 2, (ny - image_size[1]) / 2, zorder=3, alpha=.7)
2331

2432
plt.show()
2533

-11 KB
Loading

0 commit comments

Comments
 (0)
0