-
Notifications
You must be signed in to change notification settings - Fork 235
Add tutorial to explain naming of PyGMT figure elements #2383
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
Merged
Merged
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
9004d9a
Adding fig_element.py
jhtong33 3c53526
[format-command] fixes
actions-bot cb45a31
Add basemap
jhtong33 38afb47
Merge branch 'GenericMappingTools:main' into fig-element
jhtong33 21f018d
Merge branch 'GenericMappingTools:main' into fig-element
jhtong33 3c392e3
adding documentation
jhtong33 939f661
[format-command] fixes
actions-bot 7efd6de
change filename
jhtong33 6304346
documentation
jhtong33 0883745
Apply suggestions from code review
jhtong33 c3e7c37
Apply suggestions from code review
jhtong33 bb5b6c2
add pygmt.Figure docu
jhtong33 d3e7b7c
fix space
jhtong33 bbb07f6
fix paragraph
jhtong33 71f8d8c
add frame and fig.show docu
jhtong33 faf3f1d
add text docu
jhtong33 3c66d22
link modified
jhtong33 d3d2bd6
Merge branch 'GenericMappingTools:main' into fig-element
jhtong33 521b045
fix
jhtong33 f29e56c
fix L4:57
jhtong33 0afbd38
bullets change
jhtong33 5df901d
Apply suggestions from code review
jhtong33 ee362ec
Merge branch 'GenericMappingTools:main' into fig-element
jhtong33 fffeb54
use **kwargs
jhtong33 52317e0
typo
jhtong33 498ae8d
typo
jhtong33 9e3efa9
link update
jhtong33 cbfde41
Merge branch 'main' into fig-element
weiji14 c6109ef
Merge branch 'main' into fig-element
michaelgrund bfad4ee
Apply suggestions from code review
jhtong33 bb2710a
Merge branch 'GenericMappingTools:main' into fig-element
jhtong33 daed265
frame - combination of single letter.
ffa27dc
space
29944e9
Apply suggestions from code review
jhtong33 d5682e6
Apply suggestions from code review
jhtong33 3b84a1a
Apply suggestions from code review
jhtong33 f3e3bac
Apply suggestions from code review
weiji14 dcbf6b4
Merge branch 'main' into fig-element
weiji14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """ | ||
| 3. Figure elements | ||
| ================== | ||
| 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 or map boundaries (a combination of the single | ||
| letters of **WSNE**, **wsne**, or **lbtr**), adding annotations, ticks, | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| gridlines (**afg**), axis labels (**+l**), and title (**+t**), e.g., | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| in :meth:`pygmt.Figure.basemap`. Detailed examples can be found at | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| :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 | ||
| the ``label`` is given in :meth:`pygmt.Figure.plot` | ||
| - :meth:`pygmt.Figure.show`: previewing the content added to the current | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| figure instance | ||
| """ | ||
| import pygmt | ||
|
|
||
| fig = pygmt.Figure() | ||
|
|
||
| x = range(0, 11, 2) | ||
| y_1 = [10, 11, 15, 8, 9, 13] | ||
| y_2 = [4, 5, 6, 3, 5, 5] | ||
|
|
||
| fig.basemap( | ||
| region=[0, 10, 0, 20], | ||
| projection="X10c/8c", | ||
| frame=["WStr+tTitle", "xa2f1g2+lxlabel", "ya5f1g5+lylabel"], | ||
| ) | ||
| 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)") | ||
|
|
||
| mainexplain = {"font": "12p,2,darkblue", "justify": "TC", "no_clip": True} | ||
| minorexplain = {"font": "10p,8", "justify": "TC", "no_clip": True} | ||
| # ============Figure | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.text(x=12, y=22, text="Figure", **mainexplain) | ||
| fig.text(x=12, y=20.5, text="pygmt.Figure()", **minorexplain) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ============Title | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.text(x=7.5, y=22, text='frame="+tTitle"', **minorexplain) | ||
| # ============xlabel | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.text(x=5, y=-3, text='frame="x+lxlabel"', **minorexplain) | ||
| # ============ylabel | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.text(x=-1.7, y=10, text='frame="y+lylabel"', angle=90, **minorexplain) | ||
| # ============x-majorticks | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(x=10, y=-0.2, style="c1c", pen="2p,darkblue", no_clip=True) | ||
| fig.text(x=10, y=-1.4, text="Annotation", **mainexplain) | ||
| fig.text(x=10, y=-2.6, text='frame="xa2"', **minorexplain) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ============y-majorticks | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(x=-0.2, y=20, style="c1c", pen="2p,darkblue", no_clip=True) | ||
| fig.text(x=0, y=23.5, text="Annotation", **mainexplain) | ||
| fig.text(x=0, y=22, text='frame="ya5"', **minorexplain) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ============x-minorticks | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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) | ||
| # ============y-minorticks | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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) | ||
| # ============grid | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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, y=18, text='frame="xg2"', **minorexplain) | ||
weiji14 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ============map boundaries | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(x=10, y=9, style="c0.5c", pen="2p,darkblue", no_clip=True) | ||
| fig.text(x=11.5, y=8, text="Map Boundary", **mainexplain) | ||
| fig.text(x=11.5, y=6.5, text='frame="WStr"', **minorexplain) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ============fig.plot (style) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(x=6, y=8, style="c0.7c", pen="2p,darkblue") | ||
| fig.text(x=6, y=6.5, text="fig.plot(style)", **minorexplain) | ||
| # ============fig.plot (pen) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(x=4, y=6, style="c0.7c", pen="2p,darkblue") | ||
| fig.text(x=3, y=4.5, text="fig.plot(pen)", **minorexplain) | ||
| # ============Legend | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.legend() | ||
| fig.text(x=8, y=17, text="Legend", **mainexplain) | ||
jhtong33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.text(x=8, y=15.8, text="fig.legend()", **minorexplain) | ||
|
|
||
| fig.show() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.