-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Update plotting functions to use the new Matplotlib default styles #15495
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
Comments
Can you give specific examples of where the plot needs to be updated? I don't think we are using much hard-coded style elements in the plot method. If you are talking about the documentation (http://pandas.pydata.org/pandas-docs/stable/visualization.html), we are already using the |
@apcamargo Thanks for the example. Pandas does a pandas/pandas/tools/plotting.py Line 1749 in 1400305
I thought this was because matplotlib did not do that automatically when you added more lines to an ax , but that does not seem to be the case (unless that was the case for older matplotlib versions).
cc @TomAugspurger @sinhrks do you know the reason(ing) for updating the xlims based on the data? |
I think that's correct. IIRC this was changed in MPL 1.5ish. We could probably skip the |
@apcamargo Interested to make a PR to change this? |
FYI I think [this](
http://matplotlib.org/users/prev_whats_new/whats_new_1.5.html#interactive-oo-usage)
is the relevant change in matplotlib.
…On Mon, Feb 27, 2017 at 11:29 AM, Joris Van den Bossche < ***@***.***> wrote:
@apcamargo <https://github.com/apcamargo> Interested to make a PR to
change this?
If you have other examples where we conflict with the new defaults, that
is also always welcome
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIitOji5ipApVokVXhkUbwKgrJLmAks5rgwfmgaJpZM4MKwlZ>
.
|
In that whatsnew entry, they talk about 'interactive usage', so will that updating of the axes not be the case in non-interactive usage? That's not fully clear to me, but important for pandas I think if we could remove the |
So, to fix this, the line |
Yep. It should be in an if not self.mpl_ge_1_5_0():
ax.set_xlim(left, right) should work. |
We could also only do this for 2.0 and above to be safe (for lower versions it would also not have any impact, since the default xlim would be the same as what pandas now does). |
* Avoid setting xlims since recent matplotlib already does it correctly * and we should let it apply its default styles where possible (pandas-dev#15495)
* Avoid setting xlims since recent matplotlib already does it correctly * and we should let it apply its default styles where possible (pandas-dev#15495)
* Avoid setting xlims since recent matplotlib already does it correctly * and we should let it apply its default styles where possible
* Avoid setting xlims since recent matplotlib already does it correctly * and we should let it apply its default styles where possible
* Avoid setting xlims since recent matplotlib already does it correctly * and we should let it apply its default styles where possible
* Avoid setting xlims since recent matplotlib already does it correctly * and we should let it apply its default styles where possible
* 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
Closed by #16600 |
* 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
* 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
In version 2.0.0, Matplotlib introduced several changes in it's default style. Pandas plotting functions should be updated to use the new style.
http://matplotlib.org/users/dflt_style_changes.html
The text was updated successfully, but these errors were encountered: