Skip to content

Commit 0ba431d

Browse files
committed
Add doctest
1 parent d320711 commit 0ba431d

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

pygmt/params/frame.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313
class Axis(BaseParam):
1414
"""
1515
Class for setting up one axis of a plot.
16+
17+
Examples
18+
--------
19+
To specify the same attributes for all axes, with intervals of 4 for annotations,
20+
2 for ticks, and 1 for gridlines:
21+
22+
>>> import pygmt
23+
>>> fig = pygmmt.Figure()
24+
>>> fig.basemap(
25+
... region=[0, 10, 0, 20],
26+
... projection="X10c/10c",
27+
... frame=Axis(annot=4, tick=2, grid=1),
28+
... )
29+
>>> fig.show()
1630
"""
1731

1832
#: Specify the interval for annoations. It can be ``True`` to let GMT decide the
@@ -72,6 +86,43 @@ def _aliases(self):
7286
class Frame(BaseParam):
7387
"""
7488
Class for setting up the frame and axes of a plot.
89+
90+
Examples
91+
--------
92+
To specify the west and south axes with both tick marks and annotations, draw the
93+
east and north axes with tick marks but without annotations:
94+
95+
>>> import pygmt
96+
>>> fig = pygmt.Figure()
97+
>>> fig.basemap(
98+
... region=[0, 10, 0, 20], projection="X10c/10c", frame=Frame(axes="WSen")
99+
... )
100+
>>> fig.show()
101+
102+
To specify the same attributes for all axes, with intervals of 4 for annotations,
103+
2 for ticks, and 1 for gridlines:
104+
105+
>>> fig = pygmt.Figure()
106+
>>> fig.basemap(
107+
... region=[0, 10, 0, 20],
108+
... projection="X10c/10c",
109+
... frame=Frame(axes="WSrt", axis=Axis(annot=4, tick=2, grid=1)),
110+
... )
111+
... fig.show()
112+
113+
To specify the attributes for each axis separately:
114+
115+
>>> fig = pygmt.Figure()
116+
>>> fig.basemap(
117+
... region=[0, 10, 0, 20],
118+
... projection="X10c/10c",
119+
... frame=Frame(
120+
... axes="WSrt",
121+
... xaxis=Axis(annot=4, tick=2, grid=1, label="X-axis"),
122+
... yaxis=Axis(annot=5, tick=2.5, grid=1, label="Y-axis"),
123+
... ),
124+
... )
125+
... fig.show()
75126
"""
76127

77128
#: Controls which axes are drawn and whether they are annotated, using a combination

0 commit comments

Comments
 (0)