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

Matplotlib 3.0 compatibility #22790

Closed
TomAugspurger opened this issue Sep 20, 2018 · 4 comments
Closed

Matplotlib 3.0 compatibility #22790

TomAugspurger opened this issue Sep 20, 2018 · 4 comments
Labels
Blocker Blocking issue or pull request for an upcoming release Dependencies Required and optional dependencies Visualization plotting
Milestone

Comments

@TomAugspurger
Copy link
Contributor

I have some local failures with matplotlib 3.x only

========================================================================= FAILURES =========================================================================
______________________________________________________ TestTSPlot.test_matplotlib_scatter_datetime64 _______________________________________________________

self = <pandas.tests.plotting.test_datetimelike.TestTSPlot object at 0x118a34cf8>

    def test_matplotlib_scatter_datetime64(self):
        # https://github.com/matplotlib/matplotlib/issues/11391
        df = DataFrame(np.random.RandomState(0).rand(10, 2),
                       columns=["x", "y"])
        df["time"] = date_range("2018-01-01", periods=10, freq="D")
        fig, ax = self.plt.subplots()
        ax.scatter(x="time", y="y", data=df)
        fig.canvas.draw()
        label = ax.get_xticklabels()[0]
>       assert label.get_text() == '2017-12-12'
E       AssertionError: assert '2017-12-08' == '2017-12-12'
E         - 2017-12-08
E         ?         ^^
E         + 2017-12-12
E         ?         ^^

pandas/tests/plotting/test_datetimelike.py:1495: AssertionError
_________________________________________ TestDataFramePlots.test_if_scatterplot_colorbar_affects_xaxis_visibility _________________________________________

self = <pandas.tests.plotting.test_frame.TestDataFramePlots object at 0x11c340160>

    @pytest.mark.slow
    def test_if_scatterplot_colorbar_affects_xaxis_visibility(self):
        # addressing issue #10611, to ensure colobar does not
        # interfere with x-axis label and ticklabels with
        # ipython inline backend.
        random_array = np.random.random((1000, 3))
        df = pd.DataFrame(random_array,
                          columns=['A label', 'B label', 'C label'])

        ax1 = df.plot.scatter(x='A label', y='B label')
        ax2 = df.plot.scatter(x='A label', y='B label', c='C label')

        vis1 = [vis.get_visible() for vis in
                ax1.xaxis.get_minorticklabels()]
        vis2 = [vis.get_visible() for vis in
                ax2.xaxis.get_minorticklabels()]
>       assert vis1 == vis2
E       assert [] == [False, False, False, False, False, False, ...]
E         Right contains more items, first extra item: False
E         Use -v to get the full diff

pandas/tests/plotting/test_frame.py:1106: AssertionError
_________________________________________________ TestDataFramePlots.test_if_hexbin_xaxis_label_is_visible _________________________________________________

self = <pandas.tests.plotting.test_frame.TestDataFramePlots object at 0x11918ba58>

    @pytest.mark.slow
    def test_if_hexbin_xaxis_label_is_visible(self):
        # addressing issue #10678, to ensure colobar does not
        # interfere with x-axis label and ticklabels with
        # ipython inline backend.
        random_array = np.random.random((1000, 3))
        df = pd.DataFrame(random_array,
                          columns=['A label', 'B label', 'C label'])

        ax = df.plot.hexbin('A label', 'B label', gridsize=12)
>       assert all(vis.get_visible() for vis in
                   ax.xaxis.get_minorticklabels())
E       assert False
E        +  where False = all(<generator object TestDataFramePlots.test_if_hexbin_xaxis_label_is_visible.<locals>.<genexpr> at 0x11c69c990>)

pandas/tests/plotting/test_frame.py:1127: AssertionError

Our CI will start failing once these hit defaults.

@TomAugspurger TomAugspurger added Visualization plotting Dependencies Required and optional dependencies labels Sep 20, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Sep 20, 2018
@TomAugspurger TomAugspurger added the Blocker Blocking issue or pull request for an upcoming release label Sep 27, 2018
@TomAugspurger
Copy link
Contributor Author

Interestingly, I don't get the first failure from pytest pandas/tests/plotting/test_datetimelike.py::TestTSPlot::test_ts_plot_with_tz, but it does reproduce when running all the tests on that class (cc @WillAyd), so something is leaking between tests.

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Sep 28, 2018

Got lucky and found it quickly:

pytest pandas/tests/plotting/test_datetimelike.py::TestTSPlot::test_irregular_datetime64_repr_bug \
 pandas/tests/plotting/test_datetimelike.py::TestTSPlot::test_matplotlib_scatter_datetime64

fails.

@TomAugspurger
Copy link
Contributor Author

The test_if_scatterplot_colorbar_affects_xaxis_visibility and hexbin tests are failing because we implemented a hack to workaround an issue in matplotlib. That hack is no longer necessary with mil >= 3 (yay) and is actually breaking stuff, so we just need to not do it anymore.

@javadnoorb
Copy link
Contributor

I participated in that implementation. Sorry if it was too hacky and caused issues. But skipping it seems to reopen #10611 in ipython notebook when I upgrade pandas to 0.24.0rc1.

As far as I remember testing things in inline backend was a bit of a hassle, and we eventually ended up writing the tests in the default backend. Because of that my guess is that resolution of #10611 is not tested properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker Blocking issue or pull request for an upcoming release Dependencies Required and optional dependencies Visualization plotting
Projects
None yet
Development

No branches or pull requests

2 participants