Skip to content

Commit 80aff53

Browse files
Figure 2: PyGMT ecosystem (#13)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent 203d079 commit 80aff53

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

Fig2_PyGMT_ecosystem.ipynb

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "6e246dd9-2315-4af5-a906-643f2adbef42",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import pygmt\n",
11+
"\n",
12+
"red, blue = \"238/86/52\", \"#4B8BBE\" # GMT red and Python blue\n",
13+
"\n",
14+
"fig = pygmt.Figure()\n",
15+
"fig.basemap(region=[-1, 16, -0.5, 8], projection=\"x1c\", frame=0)\n",
16+
"\n",
17+
"# Add the GMT part.\n",
18+
"fig.plot(x=[-0.5, 2.5, 2.5, -0.5], y=[0, 0, 6, 6], pen=f\"2p,{red}\", fill=f\"{red}@70\", close=True)\n",
19+
"fig.vlines(x=1, ymin=1, ymax=3, pen=\"1.5p,gray30\")\n",
20+
"fig.vlines(x=1, ymin=3, ymax=5, pen=\"1.5p,gray30\")\n",
21+
"fig.plot(x=[1.0] * 3, y=[1, 3, 5], style=\"R2.1c/1c/3p\", fill=red, pen=\"0.5p\")\n",
22+
"fig.text(\n",
23+
" x=[1.0] * 4,\n",
24+
" y=[1.25, 0.75, 3, 5],\n",
25+
" text=[\"GMT low-level\", \"library\", \"GMT C API\", \"GMT modules\"] ,\n",
26+
" font=\"8p,1,white\",\n",
27+
")\n",
28+
"fig.logo(position=\"g1/6.95+jMC+w2.15c\")\n",
29+
"\n",
30+
"# Add the Python part.\n",
31+
"fig.plot(x=[7.5, 15.5, 15.5, 7.5], y=[0, 0, 6, 6], pen=f\"2p,{blue}\", fill=f\"{blue}@70\", close=True)\n",
32+
"for x, y in [\n",
33+
" ([10, 14], [1, 1]),\n",
34+
" ([10, 9], [1, 3]),\n",
35+
" ([9, 8.7], [3, 5]),\n",
36+
" ([9, 10.25], [3, 5]),\n",
37+
" ([10, 12], [1, 3]),\n",
38+
" ([12, 12], [3, 5]),\n",
39+
"]:\n",
40+
" fig.plot(x=x, y=y, pen=\"1.5p,gray30\")\n",
41+
"fig.plot(x=[10, 9, 12], y=[1, 3, 3], style=\"R2.0c/1c/3p\", fill=blue, pen=\"0.5p\")\n",
42+
"fig.plot(x=14, y=1, style=\"R2.0c/1c/3p\", fill=blue, pen=\"0.5p\")\n",
43+
"fig.text(\n",
44+
" x=[10, 9, 12, 14],\n",
45+
" y=[1, 3, 3, 1],\n",
46+
" text=[\"NumPy\", \"Xarray\", \"pandas\", \"PyArrow\"],\n",
47+
" font=\"8p,1,white\",\n",
48+
")\n",
49+
"fig.text(\n",
50+
" x=[8.7, 10.25, 12],\n",
51+
" y=[5, 5, 5],\n",
52+
" text=[\"rioxarray\", \"contextily\", \"GeoPandas\"],\n",
53+
" font=\"8p,1,white\",\n",
54+
" fill=blue,\n",
55+
" pen=\"0.5p,-\",\n",
56+
" clearance=\"0.1c/0.1c+tO\",\n",
57+
")\n",
58+
"fig.image(\n",
59+
" \"https://www.python.org/static/community_logos/python-logo-master-v3-TM.png\",\n",
60+
" position=\"g11.5/7+jMC+w4.5c\", # 7.5 + (15.5 - 7.5)\n",
61+
" bitcolor=\"white+t\",\n",
62+
")\n",
63+
"\n",
64+
"# # Add the PyGMT part.\n",
65+
"fig.pygmtlogo(position=\"g5/2.65+jMC+w2c\", wordmark=\"vertical\")\n",
66+
"fig.plot(\n",
67+
" data=[[2.6, 3, 3.9, 3], [6.1, 3, 7.4, 3]],\n",
68+
" style=\"v0.35c+a40+s+b+e+h0+ggray30\",\n",
69+
" pen=\"2p,gray30\",\n",
70+
")\n",
71+
"\n",
72+
"fig.show()\n",
73+
"fig.savefig(\"Fig2_PyGMT_ecosystem.png\")"
74+
]
75+
}
76+
],
77+
"metadata": {
78+
"kernelspec": {
79+
"display_name": "pygmt",
80+
"language": "python",
81+
"name": "python3"
82+
},
83+
"language_info": {
84+
"codemirror_mode": {
85+
"name": "ipython",
86+
"version": 3
87+
},
88+
"file_extension": ".py",
89+
"mimetype": "text/x-python",
90+
"name": "python",
91+
"nbconvert_exporter": "python",
92+
"pygments_lexer": "ipython3",
93+
"version": "3.12.7"
94+
}
95+
},
96+
"nbformat": 4,
97+
"nbformat_minor": 5
98+
}

Fig2_PyGMT_ecosystem.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import pygmt
2+
3+
red, blue = "238/86/52", "#4B8BBE" # GMT red and Python blue
4+
5+
fig = pygmt.Figure()
6+
fig.basemap(region=[-1, 16, -0.5, 8], projection="x1c", frame=0)
7+
8+
# Add the GMT part.
9+
fig.plot(x=[-0.5, 2.5, 2.5, -0.5], y=[0, 0, 6, 6], pen=f"2p,{red}", fill=f"{red}@70", close=True)
10+
fig.vlines(x=1, ymin=1, ymax=3, pen="1.5p,gray30")
11+
fig.vlines(x=1, ymin=3, ymax=5, pen="1.5p,gray30")
12+
fig.plot(x=[1.0] * 3, y=[1, 3, 5], style="R2.1c/1c/3p", fill=red, pen="0.5p")
13+
fig.text(
14+
x=[1.0] * 4,
15+
y=[1.25, 0.75, 3, 5],
16+
text=["GMT low-level", "library", "GMT C API", "GMT modules"] ,
17+
font="8p,1,white",
18+
)
19+
fig.logo(position="g1/6.95+jMC+w2.15c")
20+
21+
# Add the Python part.
22+
fig.plot(x=[7.5, 15.5, 15.5, 7.5], y=[0, 0, 6, 6], pen=f"2p,{blue}", fill=f"{blue}@70", close=True)
23+
for x, y in [
24+
([10, 14], [1, 1]),
25+
([10, 9], [1, 3]),
26+
([9, 8.7], [3, 5]),
27+
([9, 10.25], [3, 5]),
28+
([10, 12], [1, 3]),
29+
([12, 12], [3, 5]),
30+
]:
31+
fig.plot(x=x, y=y, pen="1.5p,gray30")
32+
fig.plot(x=[10, 9, 12], y=[1, 3, 3], style="R2.0c/1c/3p", fill=blue, pen="0.5p")
33+
fig.plot(x=14, y=1, style="R2.0c/1c/3p", fill=blue, pen="0.5p")
34+
fig.text(
35+
x=[10, 9, 12, 14],
36+
y=[1, 3, 3, 1],
37+
text=["NumPy", "Xarray", "pandas", "PyArrow"],
38+
font="8p,1,white",
39+
)
40+
fig.text(
41+
x=[8.7, 10.25, 12],
42+
y=[5, 5, 5],
43+
text=["rioxarray", "contextily", "GeoPandas"],
44+
font="8p,1,white",
45+
fill=blue,
46+
pen="0.5p,-",
47+
clearance="0.1c+tO",
48+
)
49+
fig.image(
50+
"https://www.python.org/static/community_logos/python-logo-master-v3-TM.png",
51+
position="g11.5/7+jMC+w4.5c", # 7.5 + (15.5 - 7.5)
52+
bitcolor="white+t",
53+
)
54+
55+
# Add the PyGMT part.
56+
fig.pygmtlogo(position="g5/2.65+jMC+w2c", wordmark="vertical")
57+
fig.plot(
58+
data=[[2.6, 3, 3.9, 3], [6.1, 3, 7.4, 3]],
59+
style="v0.35c+a40+s+b+e+h0+ggray30",
60+
pen="2p,gray30",
61+
)
62+
63+
fig.show()
64+
fig.savefig("Fig2_PyGMT_ecosystem.png")

0 commit comments

Comments
 (0)