Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/gallery/images/contours.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# %%
import numpy as np
import pygmt
from pygmt.params import Axis

# Build the contours underlying data with the function z = x^2 + y^2
X, Y = np.meshgrid(np.linspace(-10, 10, 50), np.linspace(-10, 10, 50))
Expand All @@ -34,7 +35,7 @@
fig.contour(
region=[-10, 10, -10, 10],
projection="X10c/10c",
frame="ag",
frame=Axis(annot=True, grid=True),
pen="0.5p",
# Pass the data as 3 1-D data columns
x=x,
Expand Down
3 changes: 2 additions & 1 deletion examples/gallery/symbols/bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

# %%
import pygmt
from pygmt.params import Axis

fig = pygmt.Figure()

Expand All @@ -30,7 +31,7 @@
nrows=2,
ncols=2,
subsize=("8c", "4c"),
frame="ag",
frame=Axis(annot=True, grid=True),
sharey=True,
sharex=True,
margins=["0.5c", "0.75c"],
Expand Down
18 changes: 9 additions & 9 deletions examples/tutorials/advanced/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
fig.plot(
region=[0, 10, 0, 10],
projection="X10c/10c",
frame="ag",
frame=Axis(annot=True, grid=True),
x=2,
y=8,
style="v0c",
Expand All @@ -60,7 +60,7 @@
fig.plot(
region=[0, 10, 0, 10],
projection="X10c/10c",
frame="ag",
frame=Axis(annot=True, grid=True),
x=[2, 4],
y=[8, 1],
style="v0.6c+e",
Expand All @@ -85,7 +85,7 @@
fig.plot(
region=[0, 10, 0, 10],
projection="X5i/5i",
frame="ag",
frame=Axis(annot=True, grid=True),
x=2,
y=8,
style="v1c+e",
Expand Down Expand Up @@ -122,7 +122,7 @@
fig.plot(
region=[0, 10, 0, 10],
projection="X10c/10c",
frame="ag",
frame=Axis(annot=True, grid=True),
data=vectors,
style="v0.6c+e",
pen="2p",
Expand All @@ -148,7 +148,7 @@
fig.plot(
region=[0, 10, 0, 10],
projection="X10c/10c",
frame="ag",
frame=Axis(annot=True, grid=True),
data=vectors,
style="v0.6c+e",
pen="2p",
Expand All @@ -174,7 +174,7 @@
fig.coast(
region=[-127, -64, 24, 53],
projection="M10c",
frame="ag",
frame=Axis(annot=True, grid=True),
borders=1,
shorelines="0.25p,black",
area_thresh=4000,
Expand Down Expand Up @@ -268,7 +268,7 @@
fig.plot(
region=[-5, 5, -5, 5],
projection="X10c",
frame="ag",
frame=Axis(annot=True, grid=True),
data=data,
style="m0.5c+ea",
pen="2p",
Expand Down Expand Up @@ -308,7 +308,7 @@
fig.plot(
region=[-5, 5, -5, 5],
projection="X10c",
frame="ag",
frame=Axis(annot=True, grid=True),
data=data,
style="m0.5c+ea",
pen="2p",
Expand All @@ -330,7 +330,7 @@
fig.plot(
region=[0, 10, 0, 10],
projection="X10c",
frame="ag",
frame=Axis(annot=True, grid=True),
data=[circular_vector],
style="m0.5c+ea",
pen="2p",
Expand Down
7 changes: 4 additions & 3 deletions examples/tutorials/advanced/working_with_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import numpy as np
import panel as pn
import pygmt
from pygmt.params import Axis

pn.extension()

Expand All @@ -47,7 +48,7 @@
# 15° North and a width of 12 centimeters
projection="G0/15/12c",
region="g", # global
frame="g30", # Add frame and gridlines in steps of 30 degrees on top
frame=Axis(grid=30), # Add gridlines in steps of 30 degrees on top
land="gray", # Color land masses in "gray"
water="lightblue", # Color water masses in "lightblue"
# Add coastlines with a 0.25-point thick pen in "gray50"
Expand Down Expand Up @@ -84,7 +85,7 @@ def view(central_lon):
# Vary the central longitude used for the Orthographic projection
projection=f"G{central_lon}/15/12c",
region="g",
frame="g30",
frame=Axis(grid=30),
land="gray",
water="lightblue",
shorelines="1/0.25p,gray50",
Expand Down Expand Up @@ -133,7 +134,7 @@ def view(central_lon):
region="g",
grid=grd_relief, # Use grid downloaded above
cmap=True, # Use colormap defined above
frame="g30",
frame=Axis(grid=30),
)
# Add a horizontal colorbar for the elevation.
fig.colorbar(annot=2000, tick=1000, label="Elevation", unit="m")
Expand Down
3 changes: 2 additions & 1 deletion examples/tutorials/basics/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# %%
import pygmt
from pygmt.params import Axis

# %%
# Plot frame
Expand Down Expand Up @@ -51,7 +52,7 @@

fig = pygmt.Figure()
fig.coast(shorelines="1/0.5p", region=[-180, 180, -60, 60], projection="M25c")
fig.basemap(frame="ag")
fig.basemap(frame=Axis(annot=True, grid=True))
fig.show()

# %%
Expand Down
23 changes: 12 additions & 11 deletions examples/tutorials/basics/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# %%
import pygmt
from pygmt.params import Axis

# %%
# Coordinates
Expand All @@ -32,7 +33,7 @@
# Display the shorelines and set the pen thickness to 0.5p
shorelines="1/0.5p",
# Set the frame to display annotations and gridlines
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -49,7 +50,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -69,7 +70,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -93,7 +94,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -111,7 +112,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -133,7 +134,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -154,7 +155,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -173,7 +174,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -193,7 +194,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -211,7 +212,7 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()

Expand All @@ -231,6 +232,6 @@
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
frame=Axis(annot=True, grid=True),
)
fig.show()
8 changes: 7 additions & 1 deletion pygmt/src/grdimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,19 @@ def grdimage( # noqa: PLR0913
Example
-------
>>> import pygmt
>>> from pygmt.params import Axis
>>> # load the 30 arc-minutes grid with "gridline" registration
>>> grid = pygmt.datasets.load_earth_relief("30m", registration="gridline")
>>> # create a new plot with pygmt.Figure()
>>> fig = pygmt.Figure()
>>> # pass in the grid and set the CPT to "geo"
>>> # set the projection to Mollweide and the size to 10 cm
>>> fig.grdimage(grid=grid, cmap="gmt/geo", projection="W10c", frame="ag")
>>> fig.grdimage(
... grid=grid,
... cmap="gmt/geo",
... projection="W10c",
... frame=Axis(annot=True, grid=True),
... )
>>> # show the plot
>>> fig.show()
"""
Expand Down
6 changes: 5 additions & 1 deletion pygmt/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def test_contour_matrix(array_func, data, region):
"""
fig = Figure()
fig.contour(
data=array_func(data), projection="X10c", region=region, frame="ag", pen=True
data=array_func(data),
projection="X10c",
region=region,
frame=Axis(annot=True, grid=True),
pen=True,
)
return fig

Expand Down
Loading