|
1 | 1 | """
|
2 |
| -Plotting public API |
| 2 | +Plotting public API. |
| 3 | +
|
| 4 | +Authors of third-party plotting backends should implement a module with a |
| 5 | +public ``plot(data, kind, **kwargs)``. The parameter `data` will contain |
| 6 | +the data structure and can be a `Series` or a `DataFrame`. For example, |
| 7 | +for ``df.plot()`` the parameter `data` will contain the DataFrame `df`. |
| 8 | +In some cases, the data structure is transformed before being sent to |
| 9 | +the backend (see PlotAccessor.__call__ in pandas/plotting/_core.py for |
| 10 | +the exact transformations). |
| 11 | +
|
| 12 | +The parameter `kind` will be one of: |
| 13 | +
|
| 14 | +- line |
| 15 | +- bar |
| 16 | +- barh |
| 17 | +- box |
| 18 | +- hist |
| 19 | +- kde |
| 20 | +- area |
| 21 | +- pie |
| 22 | +- scatter |
| 23 | +- hexbin |
| 24 | +
|
| 25 | +See the pandas API reference for documentation on each kind of plot. |
| 26 | +
|
| 27 | +Any other keyword argument is currently assumed to be backend specific, |
| 28 | +but some parameters may be unified and added to the signature in the |
| 29 | +future (e.g. `title` which should be useful for any backend). |
| 30 | +
|
| 31 | +Currently, all the Matplotlib functions in pandas are accessed through |
| 32 | +the selected backend. For example, `pandas.plotting.boxplot` (equivalent |
| 33 | +to `DataFrame.boxplot`) is also accessed in the selected backend. This |
| 34 | +is expected to change, and the exact API is under discussion. But with |
| 35 | +the current version, backends are expected to implement the next functions: |
| 36 | +
|
| 37 | +- plot (describe above, used for `Series.plot` and `DataFrame.plot`) |
| 38 | +- hist_series and hist_frame (for `Series.hist` and `DataFrame.hist`) |
| 39 | +- boxplot (`pandas.plotting.boxplot(df)` equivalent to `DataFrame.boxplot`) |
| 40 | +- boxplot_frame and boxplot_frame_groupby |
| 41 | +- tsplot (deprecated) |
| 42 | +- register and deregister (register converters for the tick formats) |
| 43 | +- Plots not called as `Series` and `DataFrame` methods: |
| 44 | + - table |
| 45 | + - andrews_curves |
| 46 | + - autocorrelation_plot |
| 47 | + - bootstrap_plot |
| 48 | + - lag_plot |
| 49 | + - parallel_coordinates |
| 50 | + - radviz |
| 51 | + - scatter_matrix |
| 52 | +
|
| 53 | +Use the code in pandas/plotting/_matplotib.py and |
| 54 | +https://github.com/pyviz/hvplot as a reference on how to write a backend. |
| 55 | +
|
| 56 | +For the discussion about the API see |
| 57 | +https://github.com/pandas-dev/pandas/issues/26747. |
3 | 58 | """
|
4 | 59 | from pandas.plotting._core import (
|
5 |
| - FramePlotMethods, SeriesPlotMethods, boxplot, boxplot_frame, |
6 |
| - boxplot_frame_groupby, hist_frame, hist_series) |
| 60 | + PlotAccessor, boxplot, boxplot_frame, boxplot_frame_groupby, hist_frame, |
| 61 | + hist_series) |
7 | 62 | from pandas.plotting._misc import (
|
8 | 63 | andrews_curves, autocorrelation_plot, bootstrap_plot,
|
9 | 64 | deregister as deregister_matplotlib_converters, lag_plot,
|
10 | 65 | parallel_coordinates, plot_params, radviz,
|
11 | 66 | register as register_matplotlib_converters, scatter_matrix, table)
|
12 | 67 |
|
13 |
| -__all__ = ['boxplot', 'boxplot_frame', 'boxplot_frame_groupby', 'hist_frame', |
14 |
| - 'hist_series', 'FramePlotMethods', 'SeriesPlotMethods', |
15 |
| - 'scatter_matrix', 'radviz', 'andrews_curves', 'bootstrap_plot', |
16 |
| - 'parallel_coordinates', 'lag_plot', 'autocorrelation_plot', |
17 |
| - 'table', 'plot_params', 'register_matplotlib_converters', |
| 68 | +__all__ = ['PlotAccessor', 'boxplot', 'boxplot_frame', 'boxplot_frame_groupby', |
| 69 | + 'hist_frame', 'hist_series', 'scatter_matrix', 'radviz', |
| 70 | + 'andrews_curves', 'bootstrap_plot', 'parallel_coordinates', |
| 71 | + 'lag_plot', 'autocorrelation_plot', 'table', 'plot_params', |
| 72 | + 'register_matplotlib_converters', |
18 | 73 | 'deregister_matplotlib_converters']
|
0 commit comments