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

Skip to content

sticky_edges behavior is not consistent within/across subpots #15967

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

Closed
mwaskom opened this issue Dec 17, 2019 · 5 comments
Closed

sticky_edges behavior is not consistent within/across subpots #15967

mwaskom opened this issue Dec 17, 2019 · 5 comments

Comments

@mwaskom
Copy link

mwaskom commented Dec 17, 2019

Bug report

Bug summary

I am trying to draw lines that do not get a margin placed around them when the axis is autoscaled. My understanding is that the current way to accomplish that is with Artist.sticky_edges. But I am finding that while this works within a single Axes, it does not work across multiple Axes

Code for reproduction

This works:

f, ax = plt.subplots()

ax.scatter([0, 1], [0, 0])
x1 = ax.get_xlim()
line, = ax.plot(x1, [0, 0])
line.sticky_edges.x[:] = x1

ax.scatter([0, 1], [1, 1])
x2 = ax.get_xlim()
line, = ax.plot(x2, [1, 1])
line.sticky_edges.x[:] = x2

assert x1 == x2

While this fails:

f, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)

ax1.scatter([0, 1], [0, 0])
x1 = ax1.get_xlim()
line, = ax1.plot(x1, [0, 0])
line.sticky_edges.x[:] = x1

ax2.scatter([0, 1], [1, 1])
x2 = ax2.get_xlim()
line, = ax2.plot(x2, [1, 1])
line.sticky_edges.x[:] = x2

assert x1 == x2

Is this expected to work? I know there are active changes to the autoscaling behavior; is this a bug that has been fixed (I'm not in a position to test things on a development build right now). Is there a different way to accomplish "ignore an artist when autoscaling"?

Matplotlib version

  • Operating system: macos
  • Matplotlib version: 3.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): inline
  • Python version: 3.7
@anntzer
Copy link
Contributor

anntzer commented Dec 17, 2019

Likely #15595 (pretty close to merging I think, just need to allocate some time for it...) will help?
sticky_edges across shared axes should work, but bugs may be present for sure.

@mwaskom
Copy link
Author

mwaskom commented Dec 17, 2019

That method does look useful, although I like how sticky_edges has axis-specificity, which set_in_autoscale appears not to have?

@anntzer
Copy link
Contributor

anntzer commented Dec 17, 2019

Fair point, I guess set_in_autoscale could allow ("relatively" easily) controlling x/y separately, do you want to leave a note in #15595 to that effect?

@mwaskom
Copy link
Author

mwaskom commented May 6, 2021

FYI this seems to have been fixed at some point. I'm going to close, but if someone knows why/when it was fixed that would be helpful, because it just caused my pinned CI build to fail.

@mwaskom mwaskom closed this as completed May 6, 2021
mwaskom added a commit to mwaskom/seaborn that referenced this issue May 6, 2021
@QuLogic
Copy link
Member

QuLogic commented May 6, 2021

The original example was fixed in 167105f. #16450, and 3.2.0.

mwaskom added a commit to mwaskom/seaborn that referenced this issue May 6, 2021
* Only set sticky edges on regression line when not truncating

* Improve how datalimits are established for non-truncated lines

Fixes #2509

* Add facet_kws to lmplot

Closes #2518

* Update release notes

* Skip test that fails because of matplotlib bug

xref matplotlib/matplotlib#15967

* Always set datalims using float data

* Deprecate sharex/sharey/legend_out from lmplot signature

* Tweak release note [skip ci]
mwaskom added a commit to mwaskom/seaborn that referenced this issue Aug 6, 2021
* Only set sticky edges on regression line when not truncating

* Improve how datalimits are established for non-truncated lines

Fixes #2509

* Add facet_kws to lmplot

Closes #2518

* Update release notes

* Skip test that fails because of matplotlib bug

xref matplotlib/matplotlib#15967

* Always set datalims using float data

* Deprecate sharex/sharey/legend_out from lmplot signature

* Tweak release note [skip ci]

(cherry picked from commit 3750373)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants