Skip to content

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

Closed

Description

@naught101

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  

Activity

  1. jklymak commented on Dec 12, 2017

    @jklymak
    Member

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

  2. naught101 commented on Dec 12, 2017

    @naught101
    Author

    No, plot() doesn't do that.

  3. changed the title [-]Axis limits are set badly with small values.[/-] [+]Axis limits are set badly with small values in scatter().[/+] on Dec 12, 2017
  4. LucyTishkina commented on Mar 16, 2018

    @LucyTishkina

    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.

  5. tacaswell commented on Mar 16, 2018

    @tacaswell
    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.

  6. added this to the milestone on Mar 16, 2018
  7. modified the milestones: v3.0, v3.1 on Aug 11, 2018
  8. jzwinck commented on Nov 29, 2018

    @jzwinck

    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.

  9. modified the milestones: v3.1.0, v3.2.0 on Mar 18, 2019
  10. anntzer commented on Aug 6, 2019

    @anntzer
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions