Skip to content
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

Why is smart_bounds() being deprecated? #15417

Closed
cristobaltapia opened this issue Oct 14, 2019 · 15 comments
Closed

Why is smart_bounds() being deprecated? #15417

cristobaltapia opened this issue Oct 14, 2019 · 15 comments
Milestone

Comments

@cristobaltapia
Copy link

I am getting the following warning when running my code that uses smart_bounds:

The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed 
two minor releases later.

What should we use to get the same effect in the future then?

@jklymak
Copy link
Member

jklymak commented Oct 14, 2019

What effect are you trying to achieve. This was relatively robustly discussed in the PR. You can look up the issue using the search function

@cristobaltapia
Copy link
Author

I read the PR, but was not clear to me why the functionality was not deemed important. What I want is for the axis to span only the region where the datapoints are.

@jklymak
Copy link
Member

jklymak commented Oct 14, 2019

ax.margins(0) does that, I think?

@cristobaltapia
Copy link
Author

No, that is not what I meant. What I mean is e.g. if I set the limits of the y-axis to span [0-100] but my data spans [20-100], then the left spine would by drawn starting from 20 up to 100. But there will be an empty space from 0 to 20 (no line would be drawn).

@jklymak
Copy link
Member

jklymak commented Oct 14, 2019

spine.set_bounds(x.min(), x.max())? https://matplotlib.org/3.1.1/api/spines_api.html#matplotlib.spines.Spine.set_bounds

I think the feature was deemed a bit strange to merit the amount of code and maintenance involved. But if you can make a strong case for it being useful folks may change their minds. (ping @efiring)

@tacaswell
Copy link
Member

xref #11004

@cristobaltapia
Copy link
Author

Well, I don't have strong sentiments attached to the function (although I have used it a lot in the past couple of years), but I think the functionality is nice. I read in Tufte's book [1] about the concept of "double-functioning labels", where the idea is to mark the range of your data with the spine. In the details it is not exactly as what set_smart_bounds() does, but quite similar. However, I guess that using spine.set_bounds(x.min(), x.max()) is also a viable solution.

[1] Tufte, Edward R. (1986). "The Visual Display of Quantitative Information", Graphics Press, Cheshire, CT, USA

@jklymak
Copy link
Member

jklymak commented Oct 14, 2019

Sure, but why wouldn't you just set the xlim to [20, 100] and not have the blank space?

@cristobaltapia
Copy link
Author

In the case where it is relevant to have the zero as well. If I am showing some ratios it helps to have the full range from zero, so that the magnitude is correctly interpreted.

@jklymak
Copy link
Member

jklymak commented Oct 14, 2019

How does the viewer know zero is there somewhere? Maybe you could show an example?

@tacaswell
Copy link
Member

One of the hardest things for us to know is what parts of the library are actually used. It is good to know this feature actually has users :)

I think the question is how are you using it and how onerous the alternatives are?

@tacaswell tacaswell added this to the v3.2.0 milestone Oct 14, 2019
@cristobaltapia
Copy link
Author

cristobaltapia commented Oct 15, 2019

Here are some examples:

The first one is what I described above, where I have some ratios and it is important to know where zero is (so that large variations actually mean large variations and not just that we are in a different scale). I think is nice sometimes to just mark the range this way.

figure_1

The other way I use it is in normal plots, where I just like the effect of the spines to be separated, like this:

figure_2

Maybe in the first example (as pointed out by @jklymak) it would be better to also mark the zero in the y-axis. But those are my main uses for the function.

@jklymak
Copy link
Member

jklymak commented Oct 15, 2019

Seems those would both work w/ set_bounds?

@cristobaltapia
Copy link
Author

Yes, it would. The set_smart_bounds() is (as I see it) only a shortcut, especially useful when more than one data set is plotted (then the maximum and minimum of all the plotted data has to be considered).

@efiring
Copy link
Member

efiring commented Oct 22, 2019

Given that set_bounds seems adequate for the use cases, and has the advantage of being clear and explicit, I think this can be closed.

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

4 participants