-
Notifications
You must be signed in to change notification settings - Fork 229
Offsets "X" and "Y" provide unexpected results when provided #380
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
Comments
This is neither a pygmt bug nor a GMT bug. This is how GMT works. For GMT modern mode, the paper size is about 10 meters by 10 meters, and the plot origin is located at the lower-left corner of the large paper, with offsets of 10 cm in both x and y directions. Giving X=0 and Y=0 means you're shifting the plot origin to the exactly lower-left corner of the paper, and there are no spaces for labels of the left and bottom sides. |
GMT says the following
To me, this means that X=0 and Y=0 should not change the origin, because you are adding 0 to the current value. Could you tell me what the default values of X and Y are if they are not zero? |
Also see the explanations in the cookbook https://docs.generic-mapping-tools.org/latest/cookbook/options.html#plot-positioning-and-layout-the-x-y-options. |
I just realized that the link above isn't updated for modern mode. So if you're not familiar with GMT classic mode, it may make you more confused. |
I confirm that GMT has the same behavior as pygmt, but I am still not convinced that this should be the expected behavior for pygmt. Let me see if I can make my case. Let's take a method like
X and Y set the absolute origin at (0, 0): i.e., the bottom-left of the page. However, if I call basemap again
X and Y shift the origin with respect to the current value. To me, it would be more loigical to do the following:
Then when you call
the X and Y offsets would be relative to the origin specified when creating the figure. Why do I care about this?The reason I care is because I am writing my own plotting function that takes as input a preexisting pygmt figure and optional values for the X and Y offsets. The idea was to set the default values of the X and Y offsets to zero, and then pass these to pygmt if these weren't specified. However, with the way pygmt is set up now I would need to set the default offsets to None and then do something like
|
I agree that the behavior of X and Y is not intuitive. What we can do in pygmt is limited by the core GMT. Currently I don't see a way to implement the behavior similar to what you just described. Let's see if others have better thoughts. For your use case, a workaround is to set the default offsets to
|
As a start, I think that |
As discussed in #514, the behavior of -X0 and -Y0 is correct. We can do nothing unless GMT changes how -X and -Y works in modern mode. So I believe we can almost close the issue.
But this comment is interesting. Like |
Everything works fine when making a single plot using
grdimage
when the offsetsX
andY
are not provided. Here is an example:However, if I provide the options
X=0, Y=0
, the plot is shifted to the lower left, and the left and bottom labels are cut off the plot:It appears that the left and bottom of the image are perfectly aligned with the bottom of the plot, suggesting that the size of the left and bottom labels has not been taken into account correctly.
The text was updated successfully, but these errors were encountered: