Skip to content

Commit d853ae4

Browse files
committed
Merge branch 'main' into copilot/update-figure-map-usage
2 parents a47bd3a + 8c5044e commit d853ae4

6 files changed

Lines changed: 57 additions & 29 deletions

File tree

examples/gallery/embellishments/colorbars_multiple.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# %%
1212
import pygmt
13+
from pygmt.params import Axis
1314

1415
fig = pygmt.Figure()
1516

@@ -28,15 +29,17 @@
2829
pygmt.makecpt(cmap="gmt/geo", series=[-8000, 8000])
2930
# "R?" means Winkel Tripel projection with map width automatically determined
3031
# from the subplot width.
31-
fig.grdimage(grid=grid_globe, projection="R?", region="g", frame="a")
32+
fig.basemap(projection="R?", region="g", frame=Axis(annot=True))
33+
fig.grdimage(grid=grid_globe)
3234
fig.colorbar(annot=4000, tick=2000, label="Elevation", unit="m")
3335
# Activate the second panel so that the colormap created by the makecpt function is
3436
# a panel-level CPT
3537
with fig.set_panel(panel=1):
3638
pygmt.makecpt(cmap="gmt/globe", series=[-6000, 3000])
3739
# "M?" means Mercator projection with map width also automatically determined
3840
# from the subplot width.
39-
fig.grdimage(grid=grid_subset, projection="M?", region=subset_region, frame="a")
41+
fig.basemap(projection="M?", region=subset_region, frame=Axis(annot=True))
42+
fig.grdimage(grid=grid_subset)
4043
fig.colorbar(annot=2000, tick=1000, label="Elevation", unit="m")
4144

4245
fig.show()

examples/gallery/embellishments/inset.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@
99

1010
# %%
1111
import pygmt
12-
from pygmt.params import Box, Position
12+
from pygmt.params import Axis, Box, Position
1313

1414
fig = pygmt.Figure()
15-
# Create the primary figure, setting the region to Madagascar, the land color to
16-
# "brown", the water to "lightblue", the shorelines width to "thin", and adding a frame
17-
fig.coast(region="MG+r2", land="brown", water="lightblue", shorelines="thin", frame="a")
18-
# Create an inset, placing it in the Top Left (TL) corner with a width of 3.5 cm and
19-
# x- and y-offsets of 0.2 cm. The clearance is set to 0, and the border is "gold" with a
15+
# Create the primary figure, setting the region to Madagascar
16+
fig.basemap(region="MG+r2", projection="M12c", frame=Axis(annot=True))
17+
# Set the land color to "brown", the water color to "lightblue", and the shorelines
18+
# width to "thin"
19+
fig.coast(land="brown", water="lightblue", shorelines="thin")
20+
21+
# Create an inset, placing it in the Top Left (TL) corner with a width of 3.5 cm and x-
22+
# and y-offsets of 0.2 cm. The clearance is set to 0, and the border is "gold" with a
2023
# pen thickness of 1.5 points.
2124
with fig.inset(
2225
position=Position("TL", offset=0.2),
2326
width=3.5,
2427
clearance=0,
2528
box=Box(pen="1.5p,gold"),
2629
):
27-
# Create a figure in the inset using coast. This example uses the azimuthal
28-
# orthogonal projection centered at 47E, 20S. The land color is set to "gray" and
29-
# Madagascar is highlighted in "red3".
30-
fig.coast(
31-
region="g", projection="G47/-20/?", land="gray", water="white", dcw="MG+gred3"
32-
)
30+
# Create a map within the inset. This example uses the azimuthal orthogonal
31+
# projection centered at 47 E, 20 S. The question mark is required for the
32+
# automatic size determination by PyGMT
33+
fig.basemap(region="g", projection="G47/-20/?", frame=0)
34+
# Madagascar is highlighted in "red3"
35+
fig.coast(land="gray", water="white", dcw="MG+gred3")
3336
fig.show()

examples/gallery/embellishments/inset_rectangle_region.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99

1010
# %%
1111
import pygmt
12-
from pygmt.params import Box, Position
12+
from pygmt.params import Axis, Box, Frame, Position
1313

1414
# Set the region of the main figure
1515
region = [137.5, 141, 34, 37]
1616

1717
fig = pygmt.Figure()
1818
# Plot the base map of the main figure. Universal Transverse Mercator (UTM) projection
1919
# is used and the UTM zone is set to be "54S".
20-
fig.basemap(region=region, projection="U54S/12c", frame=["WSne", "af"])
20+
fig.basemap(
21+
region=region,
22+
projection="U54S/12c",
23+
frame=Frame(axes="WSne", axis=Axis(annot=True, tick=True)),
24+
)
2125

2226
# Set the land color to "lightbrown", the water color to "azure1", the shoreline width
2327
# to "2p", and the area threshold to 1000 km^2 for the main figure.

examples/gallery/embellishments/legend.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# %%
1717
import numpy as np
1818
import pygmt
19-
from pygmt.params import Position
19+
from pygmt.params import Axis, Frame, Position
2020

2121
# Set up some test data
2222
x = np.arange(-10, 10.2, 0.2)
@@ -31,7 +31,11 @@
3131
fig.basemap(
3232
projection="X10c/7c",
3333
region=[-10, 10, -3.5, 3.5],
34-
frame=["WSne", "xaf+lx", "ya1f0.5+ly"],
34+
frame=Frame(
35+
axes="WSne",
36+
xaxis=Axis(annot=True, tick=True, label="x"),
37+
yaxis=Axis(annot=1, tick=0.5, label="y"),
38+
),
3539
)
3640

3741
# -----------------------------------------------------------------------------

examples/gallery/embellishments/scalebar.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88

99
# %%
1010
import pygmt
11-
from pygmt.params import Box, Position
11+
from pygmt.params import Axis, Box, Frame, Position
1212

1313
# Create a new Figure instance
1414
fig = pygmt.Figure()
1515

1616
# Mercator projection with 10 centimeters width
17-
fig.basemap(region=[-45, -25, -15, 0], projection="M0/0/10c", frame=["WSne", "af"])
17+
fig.basemap(
18+
region=[-45, -25, -15, 0],
19+
projection="M0/0/10c",
20+
frame=Frame(axes="WSne", axis=Axis(annot=True, tick=True)),
21+
)
1822

1923
# --- Top Left: Add a plain scale bar ---
2024
# It is placed based on geographic coordinates 42° West and 1° South, applies at the
@@ -67,7 +71,11 @@
6771

6872
fig = pygmt.Figure()
6973

70-
fig.basemap(region=[-45, -25, -15, 0], projection="M10c", frame=["WSne", "af"])
74+
fig.basemap(
75+
region=[-45, -25, -15, 0],
76+
projection="M10c",
77+
frame=Frame(axes="WSne", axis=Axis(annot=True, tick=True)),
78+
)
7179
fig.coast(land="tan", water="steelblue")
7280
fig.scalebar(
7381
position=Position("BL", cstype="inside", offset=1),

examples/gallery/histograms/blockm.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# %%
1212
import pygmt
13+
from pygmt.params import Axis, Frame
1314

1415
# Load sample data
1516
data = pygmt.datasets.load_sample_data(name="japan_quakes")
@@ -29,12 +30,15 @@
2930
# Convert to grid
3031
grd = pygmt.xyz2grd(data=df, region=region, spacing=spacing)
3132

32-
fig.grdimage(
33-
grid=grd,
33+
fig.basemap(
3434
region=region,
35-
frame=["af", "+tMean earthquake depth inside each block"],
36-
cmap="SCM/batlow",
35+
projection="M11c",
36+
frame=Frame(
37+
axis=Axis(annot=True, tick=True),
38+
title="Mean earthquake depth inside each block",
39+
),
3740
)
41+
fig.grdimage(grid=grd, cmap="SCM/batlow")
3842
# Plot slightly transparent landmasses on top
3943
fig.coast(land="darkgray", transparency=40)
4044
# Plot original data points
@@ -48,12 +52,14 @@
4852
df = pygmt.blockmean(data=data, region=region, spacing=spacing, summary="n")
4953
grd = pygmt.xyz2grd(data=df, region=region, spacing=spacing)
5054

51-
fig.grdimage(
52-
grid=grd,
55+
fig.basemap(
5356
region=region,
54-
frame=["af", "+tNumber of points inside each block"],
55-
cmap="SCM/batlow",
57+
projection="M11c",
58+
frame=Frame(
59+
axis=Axis(annot=True, tick=True), title="Number of points inside each block"
60+
),
5661
)
62+
fig.grdimage(grid=grd, cmap="SCM/batlow")
5763
fig.coast(land="darkgray", transparency=40)
5864
fig.plot(x=data.longitude, y=data.latitude, style="c0.3c", fill="white", pen="1p,black")
5965
fig.colorbar(label="Count")

0 commit comments

Comments
 (0)