Skip to content

Commit 060b723

Browse files
seismanweiji14
andauthored
Add a gallery example for varying transparent points (#654)
Co-authored-by: Wei Ji <[email protected]>
1 parent e230308 commit 060b723

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Points with varying transparency
3+
--------------------------------
4+
5+
Points can be plotted with different transparency levels by passing in an array to the
6+
``transparency`` argument of :meth:`pygmt.Figure.plot`.
7+
"""
8+
9+
import numpy as np
10+
import pygmt
11+
12+
# prepare the input x and y data
13+
x = np.arange(0, 105, 5)
14+
y = np.ones(x.size)
15+
# transparency level in percentage from 0 (i.e., opaque) to 100
16+
transparency = x
17+
18+
fig = pygmt.Figure()
19+
fig.basemap(
20+
region=[-5, 105, 0, 2],
21+
frame=['xaf+l"Transparency level"+u%', "WSrt"],
22+
projection="X15c/6c",
23+
)
24+
fig.plot(x=x, y=y, style="c0.6c", color="blue", pen="1p,red", transparency=transparency)
25+
fig.show()

0 commit comments

Comments
 (0)