Skip to content

PLT: Delegating to plotting backend only plots of Series and DataFrame methods #27432

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

Merged
merged 1 commit into from
Jul 18, 2019
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
6 changes: 3 additions & 3 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def boxplot(
>>> type(boxplot)
<class 'numpy.ndarray'>
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.boxplot(
data,
column=column,
Expand Down Expand Up @@ -1533,7 +1533,7 @@ def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwargs):
return self(kind="hexbin", x=x, y=y, C=C, **kwargs)


def _get_plot_backend():
def _get_plot_backend(backend=None):
"""
Return the plotting backend to use (e.g. `pandas.plotting._matplotlib`).

Expand All @@ -1546,7 +1546,7 @@ def _get_plot_backend():
The backend is imported lazily, as matplotlib is a soft dependency, and
pandas can be used without it being installed.
"""
backend_str = pandas.get_option("plotting.backend")
backend_str = backend or pandas.get_option("plotting.backend")
if backend_str == "matplotlib":
backend_str = "pandas.plotting._matplotlib"
return importlib.import_module(backend_str)
22 changes: 11 additions & 11 deletions pandas/plotting/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def table(ax, data, rowLabels=None, colLabels=None, **kwargs):
-------
matplotlib table object
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.table(
ax=ax, data=data, rowLabels=None, colLabels=None, **kwargs
)
Expand All @@ -48,7 +48,7 @@ def register(explicit=True):
--------
deregister_matplotlib_converter
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
plot_backend.register(explicit=explicit)


Expand All @@ -67,7 +67,7 @@ def deregister():
--------
deregister_matplotlib_converters
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
plot_backend.deregister()


Expand Down Expand Up @@ -124,7 +124,7 @@ def scatter_matrix(
>>> df = pd.DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D'])
>>> scatter_matrix(df, alpha=0.2)
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.scatter_matrix(
frame=frame,
alpha=alpha,
Expand Down Expand Up @@ -202,7 +202,7 @@ def radviz(frame, class_column, ax=None, color=None, colormap=None, **kwds):
... })
>>> rad_viz = pd.plotting.radviz(df, 'Category') # doctest: +SKIP
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.radviz(
frame=frame,
class_column=class_column,
Expand Down Expand Up @@ -249,7 +249,7 @@ def andrews_curves(
-------
class:`matplotlip.axis.Axes`
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.andrews_curves(
frame=frame,
class_column=class_column,
Expand Down Expand Up @@ -307,7 +307,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
>>> s = pd.Series(np.random.uniform(size=100))
>>> fig = pd.plotting.bootstrap_plot(s) # doctest: +SKIP
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.bootstrap_plot(
series=series, fig=fig, size=size, samples=samples, **kwds
)
Expand Down Expand Up @@ -374,7 +374,7 @@ def parallel_coordinates(
color=('#556270', '#4ECDC4', '#C7F464'))
>>> plt.show()
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.parallel_coordinates(
frame=frame,
class_column=class_column,
Expand Down Expand Up @@ -405,7 +405,7 @@ def lag_plot(series, lag=1, ax=None, **kwds):
-------
class:`matplotlib.axis.Axes`
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.lag_plot(series=series, lag=lag, ax=ax, **kwds)


Expand All @@ -424,7 +424,7 @@ def autocorrelation_plot(series, ax=None, **kwds):
-------
class:`matplotlib.axis.Axes`
"""
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.autocorrelation_plot(series=series, ax=ax, **kwds)


Expand All @@ -451,7 +451,7 @@ def tsplot(series, plotf, ax=None, **kwargs):
FutureWarning,
stacklevel=2,
)
plot_backend = _get_plot_backend()
plot_backend = _get_plot_backend("matplotlib")
return plot_backend.tsplot(series=series, plotf=plotf, ax=ax, **kwargs)


Expand Down