Skip to content

Pandas.plot() fails to calculate the right xlims #11310

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
AKuederle opened this issue Oct 13, 2015 · 1 comment · Fixed by #16600
Closed

Pandas.plot() fails to calculate the right xlims #11310

AKuederle opened this issue Oct 13, 2015 · 1 comment · Fixed by #16600
Labels

Comments

@AKuederle
Copy link

While working with cyclic data, Pandas failed to calculate the right limits for the plot. I am not sure which exact characteristic of my data causes the problem, but I will observe if further when I have time for it. Until then, here is the notebook in which the error occurred:

http://nbviewer.ipython.org/gist/AKuederle/d7837facee0479beb6cf

The first plot is the pandas plot, which has the wrong x-limits.
The second plot is the same (or at least I thought) the same plot using matplotlib directly.
The third plot shows, that it padas issue is indeed the x-limits and not something else in plotting process

Edit:
Used package Versions:

commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Windows
OS-release: 8
machine: AMD64
processor: AMD64 Family 16 Model 10 Stepping 0, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.16.2
nose: 1.3.7
Cython: 0.23.3
numpy: 1.9.3
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.0
sphinx: 1.2.3
patsy: 0.4.0
dateutil: 2.4.1
pytz: 2015.6
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.4.3
openpyxl: 2.0.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.5
lxml: 3.4.4
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.8
pymysql: None
psycopg2: None
@jreback
Copy link
Contributor

jreback commented Oct 13, 2015

pls pd.show_versions()

@jreback jreback added the Visualization plotting label Oct 13, 2015
nmartensen added a commit to nmartensen/pandas that referenced this issue Jun 5, 2017
 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.
nmartensen added a commit to nmartensen/pandas that referenced this issue Jun 10, 2017
 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.
nmartensen added a commit to nmartensen/pandas that referenced this issue Jun 10, 2017
 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.
nmartensen added a commit to nmartensen/pandas that referenced this issue Jun 10, 2017
 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.
nmartensen added a commit to nmartensen/pandas that referenced this issue Jul 19, 2017
 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.
nmartensen added a commit to nmartensen/pandas that referenced this issue Sep 15, 2017
 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.
TomAugspurger pushed a commit that referenced this issue Sep 19, 2017
* BUG: set correct xlims for lines (#11471, #11310)

 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.

* BUG: Let new MPL automatically determine xlims (#15495)

 * Avoid setting xlims since recent matplotlib already does it correctly
 * and we should let it apply its default styles where possible

* TST: plotting: update expected results for matplotlib 2

Matplotlib 2.0 uses new defaults that cause some of our tests to fail.
This adds appropriate new sets of expected results to the following
tests in tests/plotting/test_datetimelike.py:

test_finder_daily
test_finder_quarterly
test_finder_annual
test_finder_hourly
test_finder_minutely
test_finder_monthly
test_format_timedelta_ticks_narrow
test_format_timedelta_ticks_wide

* TST: plotting: Relax some tests to work with matplotlib 2.0

Matplotlib 2.0 by default now adds some padding between the boundaries
of the data and the boundaries of the plot. This causes some of our
tests to fail if we don't relax them slightly.

  modified:   pandas/tests/plotting/test_datetimelike.py
test_irregular_ts_shared_ax_xlim
test_mixed_freq_regular_first
test_mixed_freq_regular_first_df
test_secondary_y_irregular_ts_xlim
test_secondary_y_non_ts_xlim
test_secondary_y_regular_ts_xlim

  modified:   pandas/tests/plotting/test_frame.py
test_area_lim
test_line_lim

  modified:   pandas/tests/plotting/test_series.py
test_ts_area_lim
test_ts_line_lim

* TST: Add lineplot tests with unsorted x data

Two new tests check interaction of non-monotonic x data and xlims:
test_frame / test_unsorted_index_lims
test_series / test_unsorted_index_xlim

* DOC: lineplot/xlims whatsnew entry for v0.21.0
alanbato pushed a commit to alanbato/pandas that referenced this issue Nov 10, 2017
* BUG: set correct xlims for lines (pandas-dev#11471, pandas-dev#11310)

 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.

* BUG: Let new MPL automatically determine xlims (pandas-dev#15495)

 * Avoid setting xlims since recent matplotlib already does it correctly
 * and we should let it apply its default styles where possible

* TST: plotting: update expected results for matplotlib 2

Matplotlib 2.0 uses new defaults that cause some of our tests to fail.
This adds appropriate new sets of expected results to the following
tests in tests/plotting/test_datetimelike.py:

test_finder_daily
test_finder_quarterly
test_finder_annual
test_finder_hourly
test_finder_minutely
test_finder_monthly
test_format_timedelta_ticks_narrow
test_format_timedelta_ticks_wide

* TST: plotting: Relax some tests to work with matplotlib 2.0

Matplotlib 2.0 by default now adds some padding between the boundaries
of the data and the boundaries of the plot. This causes some of our
tests to fail if we don't relax them slightly.

  modified:   pandas/tests/plotting/test_datetimelike.py
test_irregular_ts_shared_ax_xlim
test_mixed_freq_regular_first
test_mixed_freq_regular_first_df
test_secondary_y_irregular_ts_xlim
test_secondary_y_non_ts_xlim
test_secondary_y_regular_ts_xlim

  modified:   pandas/tests/plotting/test_frame.py
test_area_lim
test_line_lim

  modified:   pandas/tests/plotting/test_series.py
test_ts_area_lim
test_ts_line_lim

* TST: Add lineplot tests with unsorted x data

Two new tests check interaction of non-monotonic x data and xlims:
test_frame / test_unsorted_index_lims
test_series / test_unsorted_index_xlim

* DOC: lineplot/xlims whatsnew entry for v0.21.0
No-Stream pushed a commit to No-Stream/pandas that referenced this issue Nov 28, 2017
* BUG: set correct xlims for lines (pandas-dev#11471, pandas-dev#11310)

 * Do not assume that xdata is sorted.
 * Use numpy.nanmin() and numpy.nanmax() instead.

* BUG: Let new MPL automatically determine xlims (pandas-dev#15495)

 * Avoid setting xlims since recent matplotlib already does it correctly
 * and we should let it apply its default styles where possible

* TST: plotting: update expected results for matplotlib 2

Matplotlib 2.0 uses new defaults that cause some of our tests to fail.
This adds appropriate new sets of expected results to the following
tests in tests/plotting/test_datetimelike.py:

test_finder_daily
test_finder_quarterly
test_finder_annual
test_finder_hourly
test_finder_minutely
test_finder_monthly
test_format_timedelta_ticks_narrow
test_format_timedelta_ticks_wide

* TST: plotting: Relax some tests to work with matplotlib 2.0

Matplotlib 2.0 by default now adds some padding between the boundaries
of the data and the boundaries of the plot. This causes some of our
tests to fail if we don't relax them slightly.

  modified:   pandas/tests/plotting/test_datetimelike.py
test_irregular_ts_shared_ax_xlim
test_mixed_freq_regular_first
test_mixed_freq_regular_first_df
test_secondary_y_irregular_ts_xlim
test_secondary_y_non_ts_xlim
test_secondary_y_regular_ts_xlim

  modified:   pandas/tests/plotting/test_frame.py
test_area_lim
test_line_lim

  modified:   pandas/tests/plotting/test_series.py
test_ts_area_lim
test_ts_line_lim

* TST: Add lineplot tests with unsorted x data

Two new tests check interaction of non-monotonic x data and xlims:
test_frame / test_unsorted_index_lims
test_series / test_unsorted_index_xlim

* DOC: lineplot/xlims whatsnew entry for v0.21.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants