diff --git a/examples/gallery/images/contours.py b/examples/gallery/images/contours.py index 3bb3fc1098b..ee878211377 100644 --- a/examples/gallery/images/contours.py +++ b/examples/gallery/images/contours.py @@ -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)) @@ -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, diff --git a/examples/gallery/symbols/bars.py b/examples/gallery/symbols/bars.py index f2624d9cfb7..1dcb8f4650f 100644 --- a/examples/gallery/symbols/bars.py +++ b/examples/gallery/symbols/bars.py @@ -21,6 +21,7 @@ # %% import pygmt +from pygmt.params import Axis fig = pygmt.Figure() @@ -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"], diff --git a/examples/tutorials/advanced/vectors.py b/examples/tutorials/advanced/vectors.py index 35979936d49..b5b325cc1b0 100644 --- a/examples/tutorials/advanced/vectors.py +++ b/examples/tutorials/advanced/vectors.py @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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, @@ -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", @@ -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", @@ -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", diff --git a/examples/tutorials/advanced/working_with_panel.py b/examples/tutorials/advanced/working_with_panel.py index 55271254cd8..8d450b3a17b 100644 --- a/examples/tutorials/advanced/working_with_panel.py +++ b/examples/tutorials/advanced/working_with_panel.py @@ -25,6 +25,7 @@ import numpy as np import panel as pn import pygmt +from pygmt.params import Axis pn.extension() @@ -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" @@ -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", @@ -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") diff --git a/examples/tutorials/basics/frames.py b/examples/tutorials/basics/frames.py index b3fb466fa23..c0335f8554d 100644 --- a/examples/tutorials/basics/frames.py +++ b/examples/tutorials/basics/frames.py @@ -9,6 +9,7 @@ # %% import pygmt +from pygmt.params import Axis # %% # Plot frame @@ -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() # %% diff --git a/examples/tutorials/basics/regions.py b/examples/tutorials/basics/regions.py index 5306482502f..1d14c88cb73 100644 --- a/examples/tutorials/basics/regions.py +++ b/examples/tutorials/basics/regions.py @@ -9,6 +9,7 @@ # %% import pygmt +from pygmt.params import Axis # %% # Coordinates @@ -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() @@ -49,7 +50,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -69,7 +70,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -93,7 +94,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -111,7 +112,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -133,7 +134,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -154,7 +155,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -173,7 +174,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -193,7 +194,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -211,7 +212,7 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() @@ -231,6 +232,6 @@ water="white", borders="1/0.5p", shorelines="1/0.5p", - frame="ag", + frame=Axis(annot=True, grid=True), ) fig.show() diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index e546bd0f56a..69db2d9fafb 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -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() """ diff --git a/pygmt/tests/test_contour.py b/pygmt/tests/test_contour.py index 7924c7cdf80..9eab8254dcb 100644 --- a/pygmt/tests/test_contour.py +++ b/pygmt/tests/test_contour.py @@ -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