-
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 new method to shift plot origins #289
Conversation
@leouieda Can you help review it? |
pygmt/figure.py
Outdated
@@ -284,6 +284,27 @@ def show(self, dpi=300, width=500, method="static"): | |||
img = Image(data=png, width=width) | |||
return img | |||
|
|||
def shift_origin(self, xshift=None, yshift=None): # pylint: disable=no-self-use |
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.
def shift_origin(self, xshift=None, yshift=None): # pylint: disable=no-self-use | |
def shift_origin(self, xshift=None, yshift=None): |
@seisman you still need to call self._preprocess()
to make sure we're plotting to the right figure. This is not a great design, granted. But the only other I can think of for calling the figure
module automatically is through a metaclass, which I'm not eager to do.
pygmt/figure.py
Outdated
@@ -284,6 +284,27 @@ def show(self, dpi=300, width=500, method="static"): | |||
img = Image(data=png, width=width) | |||
return img | |||
|
|||
def shift_origin(self, xshift=None, yshift=None): # pylint: disable=no-self-use | |||
""" | |||
Shift origins in x and/or y directions. |
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.
Some more information here would be great.
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.
Thanks @seisman! Could you also add a gallery plot that uses this method? Maybe plotting an inset or something. It would be great to use it in this tutorial instead of X
: https://github.com/GenericMappingTools/pygmt/blob/master/examples/tutorials/coastlines.py#L63
to the fixed lower left corner of the page, or prepend **r** [Default] to | ||
move the origin relative to its current location. | ||
|
||
Detailed usage at http://gmt.soest.hawaii.edu/doc/latest/GMT_Docs.html#plot-positioning-and-layout-the-x-y-options |
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.
What's the best way to reference the official GMT documentation?
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 still don't know of a good way to do this yet. I'm open to suggestions. It would be best to have this as a variable somewhere and input into the docstring somehow.
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.
@leouieda Can we rename the gmt_module_docs
decorator to something like gmt_docs
, which supports following conversions:
{gmt_docs basemap} => http://gmt.soest.hawaii.edu/doc/latest/basemap.html
{gmt_docs gmt xy-full} => http://gmt.soest.hawaii.edu/doc/latest/gmt.html#xy-full
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 would actually like to get rid of most of those decorators in favor of something simpler to maintain. But I don't think there is a good way to format the docstring without using a decorator. We could certainly add that functionality. But we should be using the https://www.generic-mapping-tools.org/gmt/latest/ domain now.
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.
How about putting the raw links in the docstrings, without using a decorator or any substitutions? If someday the GMT documentation site changes, it's still easy to update all the links.
I have no idea what to add in the gallery. We should use the |
@seisman you're right about the inset. The usage in the tutorial is good as that is the intended use of the method. Thanks! |
Description of proposed changes
Add
Figure.shift_origin()
to shift plot origins.Fixes #267.
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.