Repository navigation
DOC: Update the figure element intro to use the Axis/Frame classes #4985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,25 +4,24 @@ | |||||||||
|
|
||||||||||
| The figure below shows the naming of figure elements in PyGMT. | ||||||||||
|
|
||||||||||
| - :meth:`pygmt.Figure()`: having a number of plotting methods. Every new | ||||||||||
| figure must start with the creation of a :meth:`pygmt.Figure()` instance | ||||||||||
| - ``frame``: setting plot boundaries (a combination of the single | ||||||||||
| letters of **WSNE**, **wsne**, or **lbtr**), adding annotations, ticks, | ||||||||||
| gridlines (**afg**), axis labels (**+l**), and title (**+t**), e.g., | ||||||||||
| in :meth:`pygmt.Figure.basemap`. Detailed examples can be found at | ||||||||||
| :doc:`frame and axes attributes </tutorials/basics/frames>` | ||||||||||
| - :meth:`pygmt.Figure.plot`: plotting lines or symbols based on ``pen`` | ||||||||||
| or ``style`` parameters, respectively | ||||||||||
| - :meth:`pygmt.Figure.text`: plotting text strings whereby the ``font`` | ||||||||||
| parameter adjusts fontsize, fontstyle, and color | ||||||||||
| - :meth:`pygmt.Figure.legend`: showing the naming of lines or symbols while | ||||||||||
| - :meth:`pygmt.Figure()`: having a number of plotting methods. Every new figure must | ||||||||||
| start with the creation of a :meth:`pygmt.Figure()` instance | ||||||||||
| - ``frame``: setting plot boundaries and the title with :class:`pygmt.params.Frame`, and | ||||||||||
| adding annotations, ticks, gridlines, and axis labels to each axis with | ||||||||||
| :class:`pygmt.params.Axis`, e.g., in :meth:`pygmt.Figure.basemap`. Detailed examples | ||||||||||
| can be found at :doc:`frame and axes attributes </tutorials/basics/frames>` | ||||||||||
| - :meth:`pygmt.Figure.plot`: plotting lines or symbols based on the parameters | ||||||||||
| ``pen`` or ``style``, respectively | ||||||||||
| - :meth:`pygmt.Figure.text`: plotting text strings whereby the ``font`` parameter | ||||||||||
| adjusts fontsize, fontstyle, and color | ||||||||||
| - :meth:`pygmt.Figure.legend`: showing the meaning of lines or symbols while | ||||||||||
| the ``label`` is given in :meth:`pygmt.Figure.plot` | ||||||||||
| - :meth:`pygmt.Figure.show`: previewing the content added to the current | ||||||||||
| figure instance | ||||||||||
| - :meth:`pygmt.Figure.show`: previewing the content added to the current figure instance | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| # %% | ||||||||||
| import pygmt | ||||||||||
| from pygmt.params import Axis, Frame | ||||||||||
|
|
||||||||||
| fig = pygmt.Figure() | ||||||||||
|
|
||||||||||
|
|
@@ -33,7 +32,12 @@ | |||||||||
| fig.basemap( | ||||||||||
| region=[0, 10, 0, 20], | ||||||||||
| projection="X10c/8c", | ||||||||||
| frame=["WStr+tTitle", "xa2f1g2+lxlabel", "ya5f1g5+lylabel"], | ||||||||||
| frame=Frame( | ||||||||||
| axes="WStr", | ||||||||||
| title="Title", | ||||||||||
| xaxis=Axis(annot=2, tick=1, grid=2, label="xlabel"), | ||||||||||
| yaxis=Axis(annot=5, tick=1, grid=5, label="ylabel"), | ||||||||||
| ), | ||||||||||
| ) | ||||||||||
| fig.plot(x=x, y=y_1, style="t0.3c", label="fig.plot (style)") | ||||||||||
| fig.plot(x=x, y=y_2, pen="1.5p,red", label="fig.plot (pen)") | ||||||||||
|
|
@@ -44,34 +48,35 @@ | |||||||||
| fig.text(x=12, y=22, text="Figure", **mainexplain) | ||||||||||
| fig.text(x=12, y=20.8, text="pygmt.Figure()", **minorexplain) | ||||||||||
| # ============ Title | ||||||||||
| fig.text(x=7.5, y=22, text='frame="+tTitle"', **minorexplain) | ||||||||||
| fig.text(x=8.4, y=22, text='Frame(title="Title")', **minorexplain) | ||||||||||
| # ============ xlabel | ||||||||||
| fig.text(x=5, y=-3, text='frame="x+lxlabel"', **minorexplain) | ||||||||||
| fig.text(x=5, y=-3.9, text='xaxis=Axis(label="xlabel")', **minorexplain) | ||||||||||
| # ============ ylabel | ||||||||||
| fig.text(x=-1.7, y=10, text='frame="y+lylabel"', angle=90, **minorexplain) | ||||||||||
| fig.text(x=-1.7, y=10, text='yaxis=Axis(label="ylabel")', angle=90, **minorexplain) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| # ============ x-majorticks | ||||||||||
| fig.plot(x=10, y=-0.2, style="c1c", pen="2p,darkblue", no_clip=True) | ||||||||||
| fig.text(x=10, y=-1.6, text="Annotation", **mainexplain) | ||||||||||
| fig.text(x=10, y=-2.8, text='frame="xa2"', **minorexplain) | ||||||||||
| fig.text(x=10, y=-2.8, text="xaxis=Axis(annot=2)", **minorexplain) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| # ============ y-majorticks | ||||||||||
| fig.plot(x=-0.2, y=20, style="c1c", pen="2p,darkblue", no_clip=True) | ||||||||||
| fig.text(x=0, y=23.4, text="Annotation", **mainexplain) | ||||||||||
| fig.text(x=0, y=22.2, text='frame="ya5"', **minorexplain) | ||||||||||
| fig.text(x=0, y=22.2, text="yaxis=Axis(annot=5)", **minorexplain) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| # ============ x-minorticks | ||||||||||
| fig.plot(x=1, y=-0.2, style="c0.7c", pen="2p,darkblue", no_clip=True) | ||||||||||
| fig.text(x=1, y=-1.4, text="Frame", **mainexplain) | ||||||||||
| fig.text(x=1, y=-2.6, text='frame="xf1"', **minorexplain) | ||||||||||
| fig.text(x=1, y=-2.6, text="xaxis=Axis(tick=1)", **minorexplain) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| # ============ y-minorticks | ||||||||||
| fig.plot(x=0, y=2, style="c0.7c", pen="2p,darkblue", no_clip=True) | ||||||||||
| fig.text(x=-1.5, y=1, text='frame="yf1"', **minorexplain) | ||||||||||
| fig.text(x=-2.6, y=2.3, text="yaxis=Axis(tick=1)", **minorexplain) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| # ============ Grid | ||||||||||
| fig.plot(x=2, y=15, style="c0.5c", pen="2p,darkblue") | ||||||||||
| fig.text(x=2, y=17, text="Grid", **mainexplain) | ||||||||||
| fig.text(x=2.4, y=18, text='frame=["xg2", "yg5"]', **minorexplain) | ||||||||||
| fig.text(x=2.4, y=19, text="xaxis=Axis(grid=2)", **minorexplain) | ||||||||||
| fig.text(x=2.4, y=18, text="yaxis=Axis(grid=5)", **minorexplain) | ||||||||||
|
Comment on lines
+74
to
+75
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| # ============ Plot Boundaries | ||||||||||
| fig.plot(x=10, y=9, style="c0.5c", pen="2p,darkblue", no_clip=True) | ||||||||||
| fig.text(x=11.5, y=8, text="Plot Boundary", **mainexplain) | ||||||||||
| fig.text(x=11.5, y=6.8, text='frame="WStr"', **minorexplain) | ||||||||||
| fig.text(x=12, y=6.8, text='Frame(axes="WStr")', **minorexplain) | ||||||||||
| # ============ fig.plot (style) | ||||||||||
| fig.plot(x=6, y=8, style="c0.7c", pen="2p,darkblue") | ||||||||||
| fig.text(x=7, y=6.5, text="fig.plot(style)", **minorexplain) | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe, strickly speaking it is:
But this makes the labels longer and difficult to place without overlapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a little too long. Maybe change it to a shorter version
Axis(label="xlabel"), as this tutorial is mainly for showing the figure elements, rather than teaching how to useAxis/Frame