-
Notifications
You must be signed in to change notification settings - Fork 224
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
Add a gallery example showing the usage of Figure.hlines and Figure.vlines #3755
base: main
Are you sure you want to change the base?
Conversation
/format |
/format |
/format |
Co-authored-by: Dongdong Tian <[email protected]>
Co-authored-by: Yvonne Fröhlich <[email protected]>
@@ -40,7 +40,7 @@ def hlines( | |||
- **Cartesian** coordinate system: lines are plotted as straight lines. |
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'm more inclined to call them polar/geographic coordinate system rather than polar/geographic projections. What do other think?
# add a red horizontal line at y=9 without specifying x limits | ||
fig.hlines(y=9, pen="1.5p,red3", label="Line 1") | ||
# add a gray dashed horizontal line at y=8 with x limits at 2 and 8 | ||
fig.hlines(y=8, xmin=2, xmax=8, pen="1.5p,gray30,-", label="Line 2") | ||
# add two salmon-colored horizontal lines at y=6 and y=7 both with x limits at 3 and 7 | ||
fig.hlines(y=[6, 7], xmin=3, xmax=7, pen="1.5p,salmon", label="Lines 3 & 4") | ||
# add two black dotted horizontal lines at y=4 and y=5 both with x limits at 4 and 9 | ||
fig.hlines(y=[4, 5], xmin=4, xmax=9, pen="1.5p,black,.", label="Lines 5 & 6") | ||
# add two blue horizontal lines at y=2 and y=3 with different x limits | ||
fig.hlines( | ||
y=[2, 3], xmin=[0, 1], xmax=[7, 7.5], pen="1.5p,dodgerblue3", label="Lines 7 & 8" | ||
) | ||
fig.legend(position="JBR+jBR+o0.2c", box="+gwhite+p1p") |
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.
Perhaps we can simplify the comments a little bit:
# add a red horizontal line at y=9 without specifying x limits | |
fig.hlines(y=9, pen="1.5p,red3", label="Line 1") | |
# add a gray dashed horizontal line at y=8 with x limits at 2 and 8 | |
fig.hlines(y=8, xmin=2, xmax=8, pen="1.5p,gray30,-", label="Line 2") | |
# add two salmon-colored horizontal lines at y=6 and y=7 both with x limits at 3 and 7 | |
fig.hlines(y=[6, 7], xmin=3, xmax=7, pen="1.5p,salmon", label="Lines 3 & 4") | |
# add two black dotted horizontal lines at y=4 and y=5 both with x limits at 4 and 9 | |
fig.hlines(y=[4, 5], xmin=4, xmax=9, pen="1.5p,black,.", label="Lines 5 & 6") | |
# add two blue horizontal lines at y=2 and y=3 with different x limits | |
fig.hlines( | |
y=[2, 3], xmin=[0, 1], xmax=[7, 7.5], pen="1.5p,dodgerblue3", label="Lines 7 & 8" | |
) | |
fig.legend(position="JBR+jBR+o0.2c", box="+gwhite+p1p") | |
# Add a horizontal line at y=9 | |
fig.hlines(y=9, pen="1.5p,red3", label="Line 1") | |
# Add a horizontal line at y=8 with x from 2 to 8 | |
fig.hlines(y=8, xmin=2, xmax=8, pen="1.5p,gray30,-", label="Line 2") | |
# Add two horizontal lines at y=6 and y=7 both with x from 3 to 7 | |
fig.hlines(y=[6, 7], xmin=3, xmax=7, pen="1.5p,salmon", label="Lines 3 & 4") | |
# Add two horizontal lines at y=4 and y=5 both with x from 4 to 9 | |
fig.hlines(y=[4, 5], xmin=4, xmax=9, pen="1.5p,black,.", label="Lines 5 & 6") | |
# Add two horizontal lines at y=2 and y=3 with different x limits | |
fig.hlines( | |
y=[2, 3], xmin=[0, 1], xmax=[7, 7.5], pen="1.5p,dodgerblue3", label="Lines 7 & 8" | |
) | |
fig.legend(position="JBR+jBR+o0.2c", box="+gwhite+p1p") |
# %% | ||
# Cartesian coordinate system | ||
# --------------------------- | ||
# In Cartesian projections lines are plotted as straight lines. |
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.
Should we say Cartesian/polar/geographic projections or coordinate systems? GMT usually call them "Cartesian/polar coordinate transformations and geographic projections, but I feel Cartesian/polar/geographic coordinate systems may be better?
Description of proposed changes
This PR adds a gallery example to show how the
Figure.hlines
andFigure.vlines
methods can be used.Related to #923 and #3726
Preview: https://pygmt-dev--3755.org.readthedocs.build/en/3755/gallery/lines/hlines_vlines.html#
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash command is:
/format
: automatically format and lint the code