From e6627c00bbc5888c59c2dec5586ec8a5cf66cce9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 17 Oct 2020 02:28:53 -0400 Subject: [PATCH 1/3] Add a gallery example for varying transparent points --- examples/gallery/plot/points-transparency.py | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/gallery/plot/points-transparency.py diff --git a/examples/gallery/plot/points-transparency.py b/examples/gallery/plot/points-transparency.py new file mode 100644 index 00000000000..a0086576775 --- /dev/null +++ b/examples/gallery/plot/points-transparency.py @@ -0,0 +1,25 @@ +""" +Points with varying transparency +-------------------------------- + +Plotting points with varying transparency is simply passing an array to the +``transparency`` argument. +""" + +import numpy as np +import pygmt + +# prepare the input x and y data +x = np.linspace(0, 3.0 * np.pi, 100) +y = np.sin(x) +# transparency level in percentage from 0 (i.e., opaque) to 100 +transparency = np.linspace(0, 100, x.size) + +fig = pygmt.Figure() +fig.basemap( + region=[x.min(), x.max(), y.min() * 1.1, y.max() * 1.1], + frame=["af", 'WSrt+t"Varying Transparency"'], + projection="X10c/6c", +) +fig.plot(x=x, y=y, style="c0.15c", color="blue", transparency=transparency) +fig.show() From 37fb13a856a23286110b30b9fb3d163c0c1447aa Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 19 Oct 2020 00:55:37 -0400 Subject: [PATCH 2/3] Improve the gallery example --- examples/gallery/plot/points-transparency.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/gallery/plot/points-transparency.py b/examples/gallery/plot/points-transparency.py index a0086576775..0b98057d676 100644 --- a/examples/gallery/plot/points-transparency.py +++ b/examples/gallery/plot/points-transparency.py @@ -10,16 +10,16 @@ import pygmt # prepare the input x and y data -x = np.linspace(0, 3.0 * np.pi, 100) -y = np.sin(x) +x = np.arange(0, 105, 5) +y = np.ones(x.size) # transparency level in percentage from 0 (i.e., opaque) to 100 -transparency = np.linspace(0, 100, x.size) +transparency = x fig = pygmt.Figure() fig.basemap( - region=[x.min(), x.max(), y.min() * 1.1, y.max() * 1.1], - frame=["af", 'WSrt+t"Varying Transparency"'], - projection="X10c/6c", + region=[-5, 105, 0, 2], + frame=['xaf+l"Transparency level"+u%', "WSrt"], + projection="X15c/6c", ) -fig.plot(x=x, y=y, style="c0.15c", color="blue", transparency=transparency) +fig.plot(x=x, y=y, style="c0.6c", color="blue", pen="1p,red", transparency=transparency) fig.show() From 02f37b7b3d66af4e733876ffbc29d0c6041b7e64 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 20 Oct 2020 17:07:56 -0400 Subject: [PATCH 3/3] Update examples/gallery/plot/points-transparency.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/plot/points-transparency.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/plot/points-transparency.py b/examples/gallery/plot/points-transparency.py index 0b98057d676..be6b0f56e36 100644 --- a/examples/gallery/plot/points-transparency.py +++ b/examples/gallery/plot/points-transparency.py @@ -2,8 +2,8 @@ Points with varying transparency -------------------------------- -Plotting points with varying transparency is simply passing an array to the -``transparency`` argument. +Points can be plotted with different transparency levels by passing in an array to the +``transparency`` argument of :meth:`pygmt.Figure.plot`. """ import numpy as np