Skip to content
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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

michaelgrund
Copy link
Member

@michaelgrund michaelgrund commented Jan 8, 2025

Description of proposed changes

This PR adds a gallery example to show how the Figure.hlines and Figure.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

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@michaelgrund michaelgrund added the documentation Improvements or additions to documentation label Jan 8, 2025
@michaelgrund michaelgrund added this to the 0.15.0 milestone Jan 8, 2025
@michaelgrund michaelgrund changed the title WIP: Add a gallery example showing the usage of Fig.hlines and Fig.vlines WIP: Add a gallery example showing the usage of Figure.hlines and Figure.vlines Jan 8, 2025
@michaelgrund
Copy link
Member Author

/format

@michaelgrund
Copy link
Member Author

/format

@michaelgrund michaelgrund changed the title WIP: Add a gallery example showing the usage of Figure.hlines and Figure.vlines Add a gallery example showing the usage of Figure.hlines and Figure.vlines Jan 8, 2025
@michaelgrund michaelgrund added the needs review This PR has higher priority and needs review. label Jan 8, 2025
@michaelgrund
Copy link
Member Author

/format

examples/gallery/lines/hlines_vlines.py Outdated Show resolved Hide resolved
examples/gallery/lines/hlines_vlines.py Outdated Show resolved Hide resolved
examples/gallery/lines/hlines_vlines.py Outdated Show resolved Hide resolved
examples/gallery/lines/hlines_vlines.py Outdated Show resolved Hide resolved
examples/gallery/lines/hlines_vlines.py Outdated Show resolved Hide resolved
@@ -40,7 +40,7 @@ def hlines(
- **Cartesian** coordinate system: lines are plotted as straight lines.
Copy link
Member

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?

Comment on lines +22 to +34
# 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")
Copy link
Member

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:

Suggested change
# 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.
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation needs review This PR has higher priority and needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants