Skip to content

Fix limit setting after plotting empty data - #17781

Merged
jklymak merged 5 commits into
matplotlib:masterfrom
dstansby:lim-set
Jun 29, 2020
Merged

jklymak merged 5 commits into
matplotlib:masterfrom
dstansby:lim-set

Conversation

@dstansby

@dstansby dstansby commented Jun 27, 2020 •

Copy link
Copy Markdown
Member

Fixes #17586

This was a fun one to track down... It boiled down to plotting [], [] updating the datalims with [-inf, inf], which then set ignore_existing_data_limits to False. Having non-finite limits means that ignore_existing_data_limits shouldn't be set to False though, so now check that the limits are finite.

@jklymak

jklymak commented Jun 27, 2020

Copy link
Copy Markdown
Member

Does this still work for plot? Ie can you add the same test for plot?

@dstansby

Copy link
Copy Markdown
Member Author

Seems to work fine with plot, I've updated the test. The limits are slightly different between plot and scatter (I presume because plot doesn't have markers to take into account when autoscaling).

@jklymak

jklymak commented Jun 27, 2020

Copy link
Copy Markdown
Member

Hmm. Really? We took the marker size logic out of the limits determination. I guess ideally they should be identical but if that’s beyond this PR I understand.

@tacaswell tacaswell added this to the v3.3.0 milestone Jun 28, 2020
@tacaswell

Copy link
Copy Markdown
Member

This does not seem to fix the fill_between case, do we want to hold for that fix as well or bank this fix and leave #17586 open?

Could we do this test via the check_figures_equal fixture by plotting the empty data on just one of them? That would save us from having to hard-code the expected limits.

@tacaswell

Copy link
Copy Markdown
Member

I figured out the fill_between issue (thanks for doing the hard work @dstansby !) and now it runs through the same codepath.

Will push a commit with that fix and a change to the tests soon.

@tacaswell tacaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve, but given that I now have commits on this branch, I don't want to merge it.

@dstansby

Copy link
Copy Markdown
Member Author

Thanks for tracking down fill_between and making the test a bit nicer by using ax. instead of plt.!

np.column_stack([ind[where], dep2[where]])])
if ind_dir == "y":
pts = pts[:, ::-1]
self.dataLim.update_from_data_xy(pts, self.ignore_existing_data_limits,

@jklymak jklymak Jun 28, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method get a comment that its usually meant to be called by Axes.update_datalim? We need more breadcrumbs for developers so they don't get lost amongst the many levels of redirection....

Ooops scrub that, I see that is a bbox method so general enough that folks shouldn't be looking there for axes-specific methods.

@mwaskom

mwaskom commented Jun 29, 2020

Copy link
Copy Markdown

Awesome!

@dstansby
dstansby deleted the lim-set branch June 29, 2020 21:30
QuLogic added a commit that referenced this pull request Jun 29, 2020
…781-on-v3.3.x

Backport PR #17781 on branch v3.3.x (Fix limit setting after plotting empty data)
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

Successfully merging this pull request may close these issues.

Surprising datetime autoscaling after passing empty data

4 participants