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

RFC Initial pygmt.param.Pen class for specifying pen attributes #1239

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Apr 24, 2021

Description of proposed changes

Start a pygmt.param.Pen convenience class that generates a string which can be passed into GMT's pen (-W) parameter. The Pen class is structured to be under a 'param' folder. Added three basic unit tests to ensure various width/color/style combinations
will be output correctly. Note that this is still a basic implementation, and does not include advanced + modifiers as in https://docs.generic-mapping-tools.org/latest/plot.html#w.

Preview API docs at https://pygmt-git-params-pen-gmt.vercel.app/api/generated/pygmt.param.Pen.html

Example code:

import pygmt

# Thick, purple, dashed-dot-dashed border line around some text
pen = pygmt.param.Pen(width="thick", color="purple", style="-.-")
print(pen)
# thick,purple,-.-

fig = pygmt.Figure()
fig.text(x=1, y=1, region=[0, 2, 0, 2], pen=pen, text=pen)
fig.savefig("text_pen.png")
fig.show()

produces:

text_pen

References:

Fixes #1173, part of #1082

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 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 commands are:

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

Start a `pygmt.param.Pen` convenience class that
generates a string which can be passed into GMT's
pen (-W) parameter. The Pen class is structured to be
under a 'param' folder. Added three basic unit tests
to ensure various width/color/style combinations
will be output correctly.
Placing the API docs for param.Pen under a new
'Parameters' subsection. 'Specifying pen attributes'
documentation is copied from GMT cookbook, with
examples modified to use the PyGMT syntax.
@weiji14 weiji14 added the feature Brand new feature label Apr 24, 2021
@weiji14 weiji14 added this to In Progress in Pythonic GMT arguments via automation Apr 24, 2021
@weiji14 weiji14 self-assigned this Apr 24, 2021
@weiji14
Copy link
Member Author

weiji14 commented Jul 17, 2021

/format

@weiji14 weiji14 modified the milestones: 0.5.0, 0.6.0 Sep 30, 2021
@weiji14 weiji14 modified the milestones: 0.6.0, 0.7.0 Mar 1, 2022
@weiji14 weiji14 modified the milestones: 0.7.0, 0.9.0 Jun 15, 2022
@weiji14 weiji14 removed this from the 0.9.0 milestone Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Brand new feature
Projects
Status: In Progress
Pythonic GMT arguments
  
In Progress
Development

Successfully merging this pull request may close these issues.

Add individual parameters for pen settings
2 participants