From 9b78fed157715ea9aa8af66861a5971c3b891d89 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Thu, 26 Sep 2019 18:00:47 -0400 Subject: [PATCH 1/3] When using another backend, don't do the munging ahead of time --- pandas/plotting/_core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index fe6b339c2f4c8..206ebe58577d5 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -721,6 +721,10 @@ def __call__(self, *args, **kwargs): plot_backend.__name__, self._parent, args, kwargs ) + # when using another backend, get out of the way + if plot_backend.__name__ != "pandas.plotting._matplotlib": + return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs) + kind = self._kind_aliases.get(kind, kind) if kind not in self._all_kinds: raise ValueError("{} is not a valid plot kind".format(kind)) From 29b7562cf6fca8f240b5fc4bdd76f618521094d1 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Thu, 26 Sep 2019 18:07:44 -0400 Subject: [PATCH 2/3] Fixing data --- pandas/plotting/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 206ebe58577d5..d92ce51a2736a 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -723,7 +723,7 @@ def __call__(self, *args, **kwargs): # when using another backend, get out of the way if plot_backend.__name__ != "pandas.plotting._matplotlib": - return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs) + return plot_backend.plot(self._parent, x=x, y=y, kind=kind, **kwargs) kind = self._kind_aliases.get(kind, kind) if kind not in self._all_kinds: From 228b585b0e0f8d3c748f043067741a67d3bb341c Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 5 Nov 2019 09:45:59 -0500 Subject: [PATCH 3/3] alias and test --- pandas/plotting/_core.py | 3 ++- pandas/tests/plotting/test_backend.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 89b127f2ad517..8a35e5084f55b 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -721,11 +721,12 @@ def __call__(self, *args, **kwargs): plot_backend.__name__, self._parent, args, kwargs ) + kind = self._kind_aliases.get(kind, kind) + # when using another backend, get out of the way if plot_backend.__name__ != "pandas.plotting._matplotlib": return plot_backend.plot(self._parent, x=x, y=y, kind=kind, **kwargs) - kind = self._kind_aliases.get(kind, kind) if kind not in self._all_kinds: raise ValueError("{} is not a valid plot kind".format(kind)) diff --git a/pandas/tests/plotting/test_backend.py b/pandas/tests/plotting/test_backend.py index 41b1a88b15acb..d4035f8eba102 100644 --- a/pandas/tests/plotting/test_backend.py +++ b/pandas/tests/plotting/test_backend.py @@ -86,3 +86,11 @@ def test_setting_backend_without_plot_raises(): def test_no_matplotlib_ok(): with pytest.raises(ImportError): pandas.plotting._core._get_plot_backend("matplotlib") + + +def test_extra_kinds_ok(monkeypatch, restore_backend): + # https://github.com/pandas-dev/pandas/pull/28647 + monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend) + pandas.set_option("plotting.backend", "pandas_dummy_backend") + df = pandas.DataFrame({"A": [1, 2, 3]}) + df.plot(kind="not a real kind")