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

Figure.text: Support passing in a list of angle/font/justify values #2720

Merged
merged 12 commits into from Oct 17, 2023

Conversation

seisman
Copy link
Member

@seisman seisman commented Oct 7, 2023

Description of proposed changes

Address an old feature request #483.

Example:

import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 5, 0., 2.5], projection="X5c/2.5c", frame=True)
fig.text(
    x=[2.5, 2.5],
    y=[1.0, 2.0],
    angle=[30, 50],
    justify=["TL", "BR"],
    font=["15p,Helvetica-Bold,red", "5p,Times-Italic,blue"],
    text=["TEXT1", "TEXT2 with spaces"],
)
fig.show()

Preview:
image

Note: Need to fix the bug in #2719 first.

Closes #483.

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

@seisman seisman added the feature Brand new feature label Oct 7, 2023
@seisman seisman added this to the 0.11.0 milestone Oct 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2023

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added pygmt/tests/baseline/test_text_angle_justify_font_arrays.png

Image diff(s)

Added images

  • test_text_angle_justify_font_arrays.png

Modified images

Path Old New

Report last updated at commit c39f196

Comment on lines -42 to -44
angle="sequence_comma",
font="sequence_comma",
justify="sequence_comma",
Copy link
Member Author

@seisman seisman Oct 7, 2023

Choose a reason for hiding this comment

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

These lines were initially added in #321, but they should NOT be like this.

pygmt/src/text.py Outdated Show resolved Hide resolved
@seisman seisman requested a review from a team October 16, 2023 03:44
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Oct 16, 2023
@seisman seisman merged commit 3ba53af into main Oct 17, 2023
17 checks passed
@seisman seisman deleted the text-list-support branch October 17, 2023 08:18
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Oct 17, 2023
@yvonnefroehlich
Copy link
Member

This is a nice improvement of the pygmt.Figure.text method @seisman! I am wondering whether it makes sense to expand the tutorial Plotting text to show this possibility? Additionally, to the option of Plotting from a text file to adjust angle, font, and justify individually,

@seisman
Copy link
Member Author

seisman commented Oct 18, 2023

Yes, please do it if you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Brand new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure.text: Allow passing in a list/array of angle/font/justify values to text
3 participants