Skip to content
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

COMPAT: mpl 3.0 #22870

Merged
merged 2 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ Other Enhancements
- :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`Resampler.quantile` (:issue:`15023`).
- :meth:`Index.to_frame` now supports overriding column name(s) (:issue:`22580`).
- New attribute :attr:`__git_version__` will return git commit sha of current build (:issue:`21295`).
- Compatibility with Matplotlib 3.0 (:issue:`22790`).

.. _whatsnew_0240.api_breaking:

Backwards incompatible API changes
Expand Down
1 change: 1 addition & 0 deletions pandas/plotting/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ def inner():
_mpl_ge_2_0_1 = _mpl_version('2.0.1', operator.ge)
_mpl_ge_2_1_0 = _mpl_version('2.1.0', operator.ge)
_mpl_ge_2_2_0 = _mpl_version('2.2.0', operator.ge)
_mpl_ge_3_0_0 = _mpl_version('3.0.0', operator.ge)
10 changes: 8 additions & 2 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

from pandas.plotting._compat import (_mpl_ge_1_3_1,
_mpl_ge_1_5_0,
_mpl_ge_2_0_0)
_mpl_ge_2_0_0,
_mpl_ge_3_0_0)
from pandas.plotting._style import (plot_params,
_get_standard_colors)
from pandas.plotting._tools import (_subplots, _flatten, table,
Expand Down Expand Up @@ -843,11 +844,16 @@ def _plot_colorbar(self, ax, **kwds):
# For a more detailed description of the issue
# see the following link:
# https://github.com/ipython/ipython/issues/11215

img = ax.collections[0]
cbar = self.fig.colorbar(img, ax=ax, **kwds)

if _mpl_ge_3_0_0():
# The workaround below is no longer necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

could xfail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in the plotting code itself, not in the test. The workaround is necessary for mpl < 3.0, but breaks things in mpl >= 3.0

return

points = ax.get_position().get_points()
cbar_points = cbar.ax.get_position().get_points()

cbar.ax.set_position([cbar_points[0, 0],
points[0, 1],
cbar_points[1, 0] - cbar_points[0, 0],
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/plotting/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def setup_method(self, method):
self.mpl_ge_2_0_0 = plotting._compat._mpl_ge_2_0_0()
self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1()
self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()
self.mpl_ge_3_0_0 = plotting._compat._mpl_ge_3_0_0()

if self.mpl_ge_1_4_0:
self.bp_n_objects = 7
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_high_freq(self):
freaks = ['ms', 'us']
for freq in freaks:
_, ax = self.plt.subplots()
rng = date_range('1/1/2012', periods=100000, freq=freq)
rng = date_range('1/1/2012', periods=100, freq=freq)
ser = Series(np.random.randn(len(rng)), rng)
_check_plot_works(ser.plot, ax=ax)

Expand Down Expand Up @@ -1492,7 +1492,11 @@ def test_matplotlib_scatter_datetime64(self):
ax.scatter(x="time", y="y", data=df)
fig.canvas.draw()
label = ax.get_xticklabels()[0]
assert label.get_text() == '2017-12-12'
if self.mpl_ge_3_0_0:
expected = "2017-12-08"
else:
expected = "2017-12-12"
assert label.get_text() == expected


def _check_plot_works(f, freq=None, series=None, *args, **kwargs):
Expand Down