-
Notifications
You must be signed in to change notification settings - Fork 401
Allow for a fixed label offset #5320
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
Conversation
It's backward-incompatible, right? |
|
Do you mean we already are using a negative label offset for something else? |
People may be using a negative label offset to make labels closer to the axis. |
|
OK, I can imagine people doing that. The alternative implementation would then be some sort of flag to interpret the offset the absolute way. MAP_LABEL_OFFSET=offset[unit][+a] with a modifier for absolute. Not sure if this is the first defaults setting with a modifier so perhaps that is a bad precedent. The final alternative is a separate and new defaults setting like MAP_LABEL_MODE=auto|absolute [auto]. And I guess it really should measure from the axis outward to the start of the label, be it to the base of the top of it, so that means working this into PostScript for exact height, etc. |
Is it possible to make these both customizable for x and y axes independently? For example, --MAP_LABEL_OFFSET 12p/24p --MAP_LABEL_MODE annot/axis for 12p x-axis labels relative to the annotations and 24p y-axis labels relative to the axis. Either way, I prefer MAP_LABEL_MODE to +a, but find annot/axis more descriptive than auto/absolute. |
|
I have introduced the new GMT defaults MAP_LABEL_MODE = annot|axis which can be set separately for the x and y axis via a slash. Similarly, the MAP_LABEL_OFFSET can now be given separate offsets for x and y if desired. With these upgrades we can offer support for having proper alignment of numerous y-axis labels without imposing the same condition on the x-axis. But we could, if we wish to align several sets of x labels across columns. |
|
Do you think it is possible to update the auto settings for MAP_LABEL_OFFSET to work better when MAP_LABEL_MODE is set to axis? |
|
We could, but no single value will work well I think. But I agree 8p is not it! Suggestions? |
32p seems OK. Maybe it would be worth adding a warning as well for MAP_LABEL_OFFSET=auto with MAP_LABEL_MODE=axis, like what is done if annotations are removed due to gmt.conf settings. |
|
Yes, that would be good. So 8p/32p for the two types of offsets plus warning for axis actions. Would you like to try this? |
Do you mean implementing the changes or testing? Fine doing either. |
|
Sorry, meant implementing etc. Includes doc update I think as well. |
Yes, will do. |
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
|
Sorry, I completely forgot to access these suggestions... |
|
I get the same, so looks like 6p is scaled to ~the same. It is clearly not scaling 32p to something. Not obvious anything in the code is wrong. May need to debug. |
| GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ | ||
| if (gmt_M_is_dnan (GMT->current.setting.map_label_offset[GMT_X])) { | ||
| if (GMT->current.setting.map_label_mode[GMT_X] == GMT_LABEL_AXIS) | ||
| GMT->current.setting.map_label_offset[GMT_X] = 32 * pt; |
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.
| GMT->current.setting.map_label_offset[GMT_X] = 32 * pt; | |
| GMT->current.setting.map_label_offset[GMT_X] = 32 * pt * scale; |
I set this as constant intentionally, but in retrospect scaled might be better.
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.
Do you still want this suggestion to be active?
OK, so it should not be expected to work. Thanks for the explanation. |



Description of proposed changes
See issue #5182 for background. This PR lets a negative MAP_LABEL_OFFSET be interpreted as the absolute distance from the axis to the base of the label [The default is that a positive offset is seen as a relative addition beyond the end of the annotations]. The use for this is to better align multiple y-axes plots that are stacked so that the labels align even if the annotations have different magnitudes and formats. TO demonstrate this effect I added a test based on the original poster's issue. This plot is found below this text. One remaining issue is whether of not we restrict this mechanism to just the y-axis. There are two different consequences depending on the answer:
For these reasons I favor not imposing any restriction on which axis it applies to. Also note: The offset is the exact absolute distance between axis and base of label . That means it is the same on both left and right axis, but since the base is on the right there is a difference. Another question is then if we need to ensure it works symmetrically on left and right, meaning on the right axis (and bottom) we must deal with the absolute distance to the top of the label.
Comments please.