Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make sticky edges only apply if the sticky edge is the most extreme limit point #28393

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

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

ksunden
Copy link
Member

@ksunden ksunden commented Jun 13, 2024

PR summary

Closes #28223

Essentially sticky edges has a tolerance value, but that value should be treated as single ended, rather than double ended.

That is, if the data extends beyond the sticky value, then normal margins, etc should be employed, and the sticky value is only used when the unpadded values are inside of the sticky limit.

This only happens when the values are within a relatively tight tolerance (~1e-5 relative value).
As such it was first noticed with date values, but that is not actually necessary for reproduction of the effect.

Here is the test image prior to the change, note that only one of the two bars are shown:
without_change

Here it is after the change, note that one side is stickied (no margin added), but the other side has the margin added as normal:
with_change

PR checklist

@anntzer
Copy link
Contributor

anntzer commented Jun 14, 2024

I'm a bit confused about the implementation (from a super quick skim). The intent was definitely that a sticky edge can lead to slightly cropping an artist which barely goes beyond it (because that was necessary for streamplots, see #13980). I realize this can cause problems as mentioned here; perhaps the better fix is to actually clip streamplots as needed; but then perhaps a large chunk of the code above (around the comment explaining tol) could also go away?

@ksunden
Copy link
Member Author

ksunden commented Jun 14, 2024

hmmm... my other thought is we could make it within a tolerance of the width rather than of the absolute value

If streamplots are negatively affected by this change, we did not get a test failure. That was not the usecase I was looking at though, so I'm not sure.

@tacaswell
Copy link
Member

Ah, the source of the problem is that the "bottom" of the bar is sticky, but it is sticking to the top of the axes not the bottom (right instead of left) and when the bar is small relative to its position we do not "escape" the sticky.

@anntzer
Copy link
Contributor

anntzer commented Jun 15, 2024

Agreed with @tacaswell's interpretation. I would still guess the right fix is to remove the isclose(), only allow exact matches, and fix (via clipping) streamplot accordingly.

@tacaswell tacaswell added this to the v3.9.1 milestone Jun 26, 2024
@tacaswell
Copy link
Member

I think I understand this PR now and it is a better solution than what I was thinking of doing.

I suspect that we could also fix this by coming up with a better way to compute tol (which is giving us not useful values when both x0 and x1 are large, but they are close to each other.

@ksunden ksunden changed the title Make sticky edges only apply if the sticky edge is the most extream limit point Make sticky edges only apply if the sticky edge is the most extreme limit point Jun 26, 2024
@anntzer
Copy link
Contributor

anntzer commented Jun 26, 2024

Can we try to completely remove tol?

@tacaswell
Copy link
Member

Kyle reports trying that and it broke a lot of image tests. He also had concerns that doing so might snow ball into a re-write of the sticky system which is not something we should do in a micro release.

@anntzer
Copy link
Contributor

anntzer commented Jun 27, 2024

Sure. I don't really have the time to look into this right now anyways...

@QuLogic QuLogic merged commit 74c7f9a into matplotlib:main Jun 27, 2024
40 of 41 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jun 27, 2024
QuLogic added a commit that referenced this pull request Jun 28, 2024
…393-on-v3.9.x

Backport PR #28393 on branch v3.9.x (Make sticky edges only apply if the sticky edge is the most extreme limit point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Inconsistent Visualization of Intervals in ax.barh for Different Duration Widths
4 participants