-
Notifications
You must be signed in to change notification settings - Fork 359
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
Better label rotation #1475
Better label rotation #1475
Conversation
Labels are rectangles with text and their rotation make them to overlap the map boundary, which force the current algorithm to try another rotation angle, and eventually leads to suprising rotations. This occurs because the labels are also moved along an ellipse that is defined xpadding and ypadding. This patch make the labels to move along the rectangle defined by xpadding and yappding, the one that encloses the ellipse. This sligthly increases the padding which may be sufficient to prevent labels to overlap boundaries in most situations.
Can you post an example of what effect this might have? |
Here is a view extracted from a figure that is created by unitary tests. On the left, that actual behavior, and on the right, the proposed one. Globally: some of the labels are less rotated, and some others appear. |
I actually think the addition makes the axes formatting look worse. I personally liked the rotations before... Maybe this is because of the extra locations though, so perhaps it just needs an updated locator now? |
Here is one of the reason I proposed this PR: #1560 In fact, when can even go further by not trying alternate angles that induce confusion, but play only with the padding, and just not display labels that intersect the boundary with gridline angle. |
For this example
the proposed fix in this PR produces instead of The thought with #1560 is something closer to but also with labels at the top and bottom of the plot, oriented similarly to the way labels seen at the right and left are being aligned in parallel to gridlines. |
@friedrichknuth Aligning top and bottom labels with the gridline without 90° rotation to make it more readble is choice among others. For instance with this choice, longitude labels will not longer be horizontal in classic rectangular projections (like this figure).
It's for debate. Note:
|
The issue is indeed tricky... in the example provided above
produces which helps clean things up. What remains are unexpected labels on the right side, despite the call for all labels on the right to be disabled. I think this is being discussed in part here #1530. There might be a lead in #1530 (comment) on how to mask right/left/top/bottom values based on if they are lat/lon values. In other words, if labels on a given side are being explicitly disabled, only preserve the most frequent type. Perhaps only displaying the most frequent type (lat or lon) on a given side can be the default? Not sure how this plays out in all possible projections/rotations, but it may resolve some of these alignment issues. Another thought would be to implement a toggle for |
In fact, the problem of label visibility is also tricky. For instance, what is a "right label" in this figure? As for the |
No longer valid due to #1537 |
Rationale
Labels are rectangles with text and their rotation make them
to overlap the map boundary, which force the current algorithm
to try another rotation angle, and eventually leads to suprising
rotations. This occurs because the labels are also moved along
an ellipse that is defined xpadding and ypadding.
This patch make the labels to move along the rectangle defined by xpadding
and yappding, the one that encloses the ellipse. This
sligthly increases the padding which may be sufficient to prevent
labels to overlap boundaries in most situations.
Implications
Labels should undergo less exagerated rotation in some circumstances.