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 gallery example "Decorated lines" (style="~") #2564

Merged
merged 24 commits into from
Jul 3, 2023

Conversation

yvonnefroehlich
Copy link
Member

@yvonnefroehlich yvonnefroehlich commented Jun 4, 2023

Description of proposed changes

This PR aims to add a gallery example showing how to generated "Decorated lines".

Upstream GMT documentation: https://docs.generic-mapping-tools.org/dev/plot.html#s

Related to:

Preview: https://pygmt-dev--2564.org.readthedocs.build/en/2564/gallery/lines/decorated_lines.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.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

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

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@yvonnefroehlich yvonnefroehlich added the documentation Improvements or additions to documentation label Jun 4, 2023
@yvonnefroehlich yvonnefroehlich added this to the 0.10.0 milestone Jun 4, 2023
@yvonnefroehlich yvonnefroehlich self-assigned this Jun 4, 2023
@yvonnefroehlich
Copy link
Member Author

/format

@yvonnefroehlich yvonnefroehlich marked this pull request as draft June 4, 2023 20:24
@yvonnefroehlich
Copy link
Member Author

/format

@yvonnefroehlich yvonnefroehlich added the needs review This PR has higher priority and needs review. label Jun 27, 2023
@yvonnefroehlich yvonnefroehlich changed the title WIP: Add gallery example "Decorated lines" (style="~") Add gallery example "Decorated lines" (style="~") Jun 28, 2023
@yvonnefroehlich yvonnefroehlich marked this pull request as ready for review June 28, 2023 05:58
Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@seisman seisman removed the needs review This PR has higher priority and needs review. label Jun 28, 2023
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Jun 28, 2023
@yvonnefroehlich
Copy link
Member Author

Based on the upstream GMT documentation at https://docs.generic-mapping-tools.org/dev/plot.html#s it should be possible to rotate the symbol by appending +aangle:

+aangle
Force symbols at a fixed angle, +an for line-normal, or +ap for line-parallel [Default].

However, so far this does not work for me (for quoted lines it works to rotate the label by appending +aangle).

Code example:

import pygmt
import numpy as np


size = 5
x = np.array([-size, size])
y = np.array([3, 3])

fig = pygmt.Figure()

fig.basemap(
    region=[-size, size, -size, size],
    projection="X" + str(size*2) + "c",
    frame=True,
)

for i_line in [
        "~d2c:+ss1c",
        "~d2c:+ss1c+a20",
        "qd1c:+ltext",
        "qd1c:+ltext+a20",
        ]:
    fig.plot(
        x=x,
        y=y,
        style=i_line,
        pen="1.25p,black",
    )
    
    fig.text(
        x=0,
        y=y[0]+0.7,
        text=i_line,
        font="10p",
    )
    
    y = y - 2
    
fig.show()
# fig.savefig(fname="decorated_lines_rotated.png")

Output figure:
decorated_lines_rotated

@seisman
Copy link
Member

seisman commented Jul 2, 2023

Based on the upstream GMT documentation at https://docs.generic-mapping-tools.org/dev/plot.html#s it should be possible to rotate the symbol by appending +aangle:

+aangle
Force symbols at a fixed angle, +an for line-normal, or +ap for line-parallel [Default].

However, so far this does not work for me (for quoted lines it works to rotate the label by appending +aangle).

Likely an upstream bug or a missing feature. Please report to the upstream GMT repository.

@yvonnefroehlich
Copy link
Member Author

Based on the upstream GMT documentation at https://docs.generic-mapping-tools.org/dev/plot.html#s it should be possible to rotate the symbol by appending +aangle:

+aangle
Force symbols at a fixed angle, +an for line-normal, or +ap for line-parallel [Default].

However, so far this does not work for me (for quoted lines it works to rotate the label by appending +aangle).

Likely an upstream bug or a missing feature. Please report to the upstream GMT repository.

Please see issue GenericMappingTools/gmt#7591.

@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jul 3, 2023
@seisman seisman merged commit 91e29f1 into main Jul 3, 2023
@seisman seisman deleted the add-gallery-decoratedlines branch July 3, 2023 08:57
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants