Skip to content

Axis limits are set badly with small values in scatter(). #9979

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
naught101 opened this issue Dec 12, 2017 · 6 comments
Closed

Axis limits are set badly with small values in scatter(). #9979

naught101 opened this issue Dec 12, 2017 · 6 comments
Milestone

Comments

@naught101
Copy link

I'm not sure if this is related to #7413

Bug report

Example:

%pylab
x = randn(1000) / 1e5
y = randn(1000) / 1e5
scatter(x, y)

produces this:
figure_1

It should really produce something more like this:

figure_1-2

There's not an obvious way to do this, other than manually getting the min/max x and y values and adding a little bit and using ax.set_x/ylim()

Using conda on kubuntu:

matplotlib                2.1.0            py36hba5de38_0  
python                    3.6.3                h0ef2715_3  
@jklymak
Copy link
Member

jklymak commented Dec 12, 2017

Yes, it's scatter's specialness. I bet plot doesn't do that.

@naught101
Copy link
Author

No, plot() doesn't do that.

@naught101 naught101 changed the title Axis limits are set badly with small values. Axis limits are set badly with small values in scatter(). Dec 12, 2017
@LucyTishkina
Copy link

I have been trying to see why scatter is behaving in a different way. I realized that some of the code used by scatter is in _path.h. The get_path_collection_extents method gets called from path.py to figure out the dimensions to give to the bounding box. I would be interested in pursuing this further, but I am just not sure how to debug the c++ part of the library, any tips would be appreciated.

@tacaswell
Copy link
Member

@Lusura My knee jerk reaction is that the bug is not in the c++ layer, but in how we massage the returns of those calls in python.

One of the things scatter tries to take into account is that the size of the markers can vary in size which may be related to this.

Agree is in related to #7413.

@tacaswell tacaswell added this to the v3.0 milestone Mar 16, 2018
@tacaswell tacaswell modified the milestones: v3.0, v3.1 Aug 11, 2018
@jzwinck
Copy link

jzwinck commented Nov 29, 2018

Here's a trivial demo which doesn't do what anyone would expect: https://stackoverflow.com/questions/53536688/matplotlib-automatically-sets-insane-datetime-x-axis-range

The code:

import matplotlib.pyplot as plt
import pandas as pd
plt.scatter(pd.to_datetime(['10:00', '11:00', '12:00']), [30, 40, 50])
plt.show()

The result

Summary: The simplest possible scatter plot of a time series on a single date chooses nonsensically huge x bounds, making the plot useless for visualization by default.

@tacaswell tacaswell modified the milestones: v3.1.0, v3.2.0 Mar 18, 2019
@anntzer
Copy link
Contributor

anntzer commented Aug 6, 2019

AFAICT this (both examples) has been fixed by #13642. Feel free to reopen if something is missing.

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

6 participants