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

Skip to content

Bbox.frozen() does not copy minposx/minposy #19296

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
anntzer opened this issue Jan 14, 2021 · 6 comments · Fixed by #19641
Closed

Bbox.frozen() does not copy minposx/minposy #19296

anntzer opened this issue Jan 14, 2021 · 6 comments · Fixed by #19641
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues topic: transforms and scales

Comments

@anntzer
Copy link
Contributor

anntzer commented Jan 14, 2021

Bug report

Bug summary

All's in the title.

One use case which showcases this is to prevent an artist from participating in autoscaling (in effect, a slightly hackish way to implement something like #15595):

ax = ...
dl = ax.dataLim.frozen()
ax.plot(...)
# restore old datalim, so that plot() does not participate in autoscale
ax.dataLim = dl

which works... except for log-scale, as that needs also copying minposx/minposy.

Code for reproduction

from pylab import *
plot([1, 2]); print(gca().dataLim.minposx, gca().dataLim.frozen().minposx)

Actual outcome

1.0 inf

Expected outcome

1.0 1.0

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): master (3.3.x)
  • Matplotlib backend (print(matplotlib.get_backend())): any
  • Python version: 3.9
  • Jupyter version (if applicable):
  • Other libraries:
@anntzer anntzer added the Good first issue Open a pull request against these issues if there are no active ones! label Jan 14, 2021
@Monishver
Copy link

Hello @anntzer , I'm new to open source, and would like to contribute to this issue, could you explain this issue more and navigate me a little bit.

@story645
Copy link
Member

story645 commented Jan 18, 2021

hi @Monishver! check out our development guide at https://matplotlib.org/devdocs/

The issue is that the method frozen on BBoxes parent

def frozen(self):
return Bbox(self.get_points().copy())
frozen.__doc__ = TransformNode.__doc__
does not include the minposx/minposy properties of the BBox child class when it makes its copy.

One possible solution is for Bbox to implement its own frozen method but there are probably others.

@Monishver
Copy link

Thanks for giving a detailed overview, I have started looking into it and will try to implement it in few days.

@ghost
Copy link

ghost commented Jan 26, 2021

I am new to open source and I trying to know about this issue, can you @story645 please tell how adding frozen in the Bbox class would help to resolve this issue

@story645
Copy link
Member

story645 commented Jan 26, 2021

If you overload 'frozen' by implementing it inside BBox, than you can add whichever of BBox's attributes (such as miniposx and minposy) to the attributes returned in the frozen version.

Another option is extending BBox.get_points but I don't like that approach since miniposx and miniposy aren't points.

@jklymak jklymak added Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues and removed Good first issue Open a pull request against these issues if there are no active ones! labels Jan 26, 2021
@jklymak
Copy link
Member

jklymak commented Jan 26, 2021

I've reclassified this - I don't think anything that touches the minpos machinery is a "Good first issue". Maybe its "Easy" if you know what minpos is and understand its use in the library, but given that it is almost undocumented, that requires digging through the code. Thats not to preclude this being a "first issue", but first time contributors should expect to do said digging.

m4reko added a commit to soffan-group16/matplotlib that referenced this issue Mar 2, 2021
Co-authored-by: Agriad <[email protected]>
Co-authored-by: davek10 <[email protected]>
Co-authored-by: tjr16 <[email protected]>
m4reko added a commit to soffan-group16/matplotlib that referenced this issue Mar 2, 2021
This function copies minpos when frozen is called.
This commit resolves matplotlib#19296.

Co-authored-by: Agriad <[email protected]>
Co-authored-by: davek10 <[email protected]>
Co-authored-by: tjr16 <[email protected]>
m4reko added a commit to soffan-group16/matplotlib that referenced this issue Mar 5, 2021
This function copies minpos when frozen is called.
This commit resolves matplotlib#19296.

Co-authored-by: Agriad <[email protected]>
Co-authored-by: davek10 <[email protected]>
Co-authored-by: tjr16 <[email protected]>
tjr16 pushed a commit to soffan-group16/matplotlib that referenced this issue Mar 5, 2021
tjr16 pushed a commit to soffan-group16/matplotlib that referenced this issue Mar 5, 2021
MihaiAnton pushed a commit to MihaiAnton/matplotlib that referenced this issue Mar 8, 2021
Co-authored-by: Agriad <[email protected]>
Co-authored-by: davek10 <[email protected]>
Co-authored-by: tjr16 <[email protected]>
MihaiAnton pushed a commit to MihaiAnton/matplotlib that referenced this issue Mar 8, 2021
This function copies minpos when frozen is called.
This commit resolves matplotlib#19296.

Co-authored-by: Agriad <[email protected]>
Co-authored-by: davek10 <[email protected]>
Co-authored-by: tjr16 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues topic: transforms and scales
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants