-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PLT: Cleaner plotting backend API, and unify Series and DataFrame accessors #27009
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
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f279d16
Some experiments so far
datapythonista ca5671c
Refactoring of pandas plotting to make the API clearer
datapythonista 8a56ad7
Merge remote-tracking branch 'upstream/master' into plot_api
196388b
Addressing review comments, and fixing many tests (still some tests f…
f00ec30
Merge remote-tracking branch 'upstream/master' into plot_api
1c16faa
Merge remote-tracking branch 'upstream/master' into plot_api
995d72e
Restoring docstrings of hist_series, hist_frame, boxplot and boxplot_…
7e45996
Fixing plot accessor docstring (was in the wrong place, and couple of…
4fbfed0
Fixing hexbin plot tests
7d7263a
Fixing bug when calling plot twice on the same data, since the data (…
1a03cbf
Raising missing exception for pie in DataFrame, and fixing accessor s…
cf7cbc0
Fixing bug that shown the legend for Series plot
d063e05
Fix linting
c83551d
Merge remote-tracking branch 'upstream/master' into plot_api
369fbf1
Merge remote-tracking branch 'upstream/master' into plot_api
0d146f9
Fixing bug that made reusing the previous plot for dataframes
34ea1f2
Removing duplicated data type checks
19489ba
Restoring original position of methods, so the diff is smaller
9b4fc6d
Fixing name of reuse_plot parameter
2597bc9
Fixing bug with matplotlib 2
57c4937
Adding documentation and improving comments, based on Jeff review
263ee7a
Adding FutureWarning if Series.plot is called with positional arguments
37fe165
Not passing default matplotlib parameters to backends (all known kwar…
0cf4514
Fixing test of plotting accessor parameters
4d70d5d
Temporary not warning for Series.plot positional arguments (looks lik…
a2330b2
Revert "Temporary not warning for Series.plot positional arguments (l…
42a1b35
Merge remote-tracking branch 'upstream/master' into plot_api
34d189f
Adding debug info in the CI for failing test
5819585
Revert "Adding debug info in the CI for failing test"
29d7547
Temporary removing the warning, to see if it's causing the andrews_cu…
37fb064
Merge branch 'master' into PR_TOOL_MERGE_PR_27009
jreback a5d0fd9
Revert "Temporary removing the warning, to see if it's causing the an…
datapythonista ce544e1
Removing test that causes parallel_coordinates test to fail
datapythonista File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,73 @@ | ||
""" | ||
Plotting public API | ||
Plotting public API. | ||
|
||
Authors of third-party plotting backends should implement a module with a | ||
public ``plot(data, kind, **kwargs)``. The parameter `data` will contain | ||
the data structure and can be a `Series` or a `DataFrame`. For example, | ||
for ``df.plot()`` the parameter `data` will contain the DataFrame `df`. | ||
In some cases, the data structure is transformed before being sent to | ||
the backend (see PlotAccessor.__call__ in pandas/plotting/_core.py for | ||
the exact transformations). | ||
|
||
The parameter `kind` will be one of: | ||
|
||
- line | ||
- bar | ||
- barh | ||
- box | ||
- hist | ||
- kde | ||
- area | ||
- pie | ||
- scatter | ||
- hexbin | ||
|
||
See the pandas API reference for documentation on each kind of plot. | ||
|
||
Any other keyword argument is currently assumed to be backend specific, | ||
but some parameters may be unified and added to the signature in the | ||
future (e.g. `title` which should be useful for any backend). | ||
|
||
Currently, all the Matplotlib functions in pandas are accessed through | ||
the selected backend. For example, `pandas.plotting.boxplot` (equivalent | ||
to `DataFrame.boxplot`) is also accessed in the selected backend. This | ||
is expected to change, and the exact API is under discussion. But with | ||
the current version, backends are expected to implement the next functions: | ||
|
||
- plot (describe above, used for `Series.plot` and `DataFrame.plot`) | ||
- hist_series and hist_frame (for `Series.hist` and `DataFrame.hist`) | ||
- boxplot (`pandas.plotting.boxplot(df)` equivalent to `DataFrame.boxplot`) | ||
- boxplot_frame and boxplot_frame_groupby | ||
- tsplot (deprecated) | ||
- register and deregister (register converters for the tick formats) | ||
- Plots not called as `Series` and `DataFrame` methods: | ||
- table | ||
- andrews_curves | ||
- autocorrelation_plot | ||
- bootstrap_plot | ||
- lag_plot | ||
- parallel_coordinates | ||
- radviz | ||
- scatter_matrix | ||
|
||
Use the code in pandas/plotting/_matplotib.py and | ||
https://github.com/pyviz/hvplot as a reference on how to write a backend. | ||
|
||
For the discussion about the API see | ||
https://github.com/pandas-dev/pandas/issues/26747. | ||
""" | ||
from pandas.plotting._core import ( | ||
FramePlotMethods, SeriesPlotMethods, boxplot, boxplot_frame, | ||
boxplot_frame_groupby, hist_frame, hist_series) | ||
PlotAccessor, boxplot, boxplot_frame, boxplot_frame_groupby, hist_frame, | ||
hist_series) | ||
from pandas.plotting._misc import ( | ||
andrews_curves, autocorrelation_plot, bootstrap_plot, | ||
deregister as deregister_matplotlib_converters, lag_plot, | ||
parallel_coordinates, plot_params, radviz, | ||
register as register_matplotlib_converters, scatter_matrix, table) | ||
|
||
__all__ = ['boxplot', 'boxplot_frame', 'boxplot_frame_groupby', 'hist_frame', | ||
'hist_series', 'FramePlotMethods', 'SeriesPlotMethods', | ||
'scatter_matrix', 'radviz', 'andrews_curves', 'bootstrap_plot', | ||
'parallel_coordinates', 'lag_plot', 'autocorrelation_plot', | ||
'table', 'plot_params', 'register_matplotlib_converters', | ||
__all__ = ['PlotAccessor', 'boxplot', 'boxplot_frame', 'boxplot_frame_groupby', | ||
'hist_frame', 'hist_series', 'scatter_matrix', 'radviz', | ||
'andrews_curves', 'bootstrap_plot', 'parallel_coordinates', | ||
'lag_plot', 'autocorrelation_plot', 'table', 'plot_params', | ||
'register_matplotlib_converters', | ||
'deregister_matplotlib_converters'] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should mention those right now, as there is still some discussion on whether to see them as part of the plotting backend interface or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two lines below I say that
This is expected to change
. Personally I think it adds more value to have this comment now, and remove it when/if that changes, than just not having this documented, or document the future behavior.