-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: dedicated plot methods like plot.scatter as an alternative to using kind #9124
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
Comments
I'm +1 on the accessor. We might want to group additional methods/attributes that don't fit the |
I agree with the sentiment of But, the latest evolution in pandas was actually in the opposite direction. As lately, the separate |
@jorisvandenbossche I think it was a good idea to move |
plot_* methods are pretty inflexible from s user perspective not easy to switch bar to line or whatever and really hard to do programmatically (you have to compose the method name) so big -1 on that the accessor is a bit more amenable as it then allows kw separation and tab completion should only be 1 obvious method of doing this .plot(kind=...) seems intuitive to me |
Perhaps we could just consolidate plotting methods based on their API. Off the top of my head:
From a programmatic perspective, it's nice to be able to use |
@shoyer that looks reasonable |
That said, I do still think dedicated methods/accessor would be a better API. Even within a category, there are plenty of kind specific options. On Sun, Dec 21, 2014 at 2:51 PM, jreback notifications@github.com wrote:
|
I wonder if making |
Yes, this is not a bad option, although ultimately it would probably be cleaner to have the base plot method wrap the specific types, e.g.,
"only one obvious way to do it" is great, but pandas leans a bit more toward practicality. |
I like the idea of having specific plot functions attached to If we could divide the plot types into categories like shoyer suggested that would be good too, but the proposed categories don't seem all that obvious/intuitive to me. I wouldn't have thought of a bar chart as a 1D plot (although it makes sense now that I think about it), and isn't line is either 1D or 2D depending on whether we're plotting with the index as x-axis or using a second variable? Would probably create a decent amount of confusion for people who know which kind of plot they want to find their way through to it. |
It sounds like there is support for preserving the |
+1. I like the idea of typing |
I'm Ok with this too. As far as implementation goes, do we have a df/series.plot callable that dispatches off the kind argument and then add the different .bar, .line ... methods as attributes? Do we have any examples of similar methods?
|
for implementation see here: https://github.com/pydata/pandas/blob/master/pandas/tseries/common.py#L55 just create a subclass of PandasDelegate and this is quite easy |
Yeah, having both should be better. I think reason of current plotting complexity is also caused by some options which are rarely used. Let me list up as separate issue. |
Fixes pandas-dev#9124 This PR adds plotting sub-methods like `df.plot.scatter()` as an alternative to using `df.plot(kind='scatter')`. I've added meaningful function signatures and documentation for a few of these methods, but I would greatly appreciate help to fill in the rest -- this is a lot of documentation to write! The entire point of this PR, of course, is to have better introspection and docstrings. Todo list: - [ ] Function signatures - [ ] `area` - [ ] `line` - [ ] `bar` - [ ] `barh` - [x] `box` - [x] `hexbin` - [x] `hist` - [ ] `kde`/`density` - [ ] `pie` - [x] `scatter` - [ ] Docstrings - [ ] `area` - [ ] `line` - [ ] `bar` - [ ] `barh` - [ ] `box` - [ ] `hexbin` - [x] `hist` - [ ] `kde`/`density` - [ ] `pie` - [ ] `scatter` - [ ] Tests (just a few) - [ ] Plotting docs - [ ] API docs - [ ] Release notes
I have a preliminary PR up at #9321. This should be a reasonable framework (I've verified that introspection seems to work properly with IPython), but I could definitely use help assembling appropriate function signatures and docstrings :). |
Fixes pandas-dev#9124 This PR adds plotting sub-methods like `df.plot.scatter()` as an alternative to using `df.plot(kind='scatter')`. I've added meaningful function signatures and documentation for a few of these methods, but I would greatly appreciate help to fill in the rest -- this is a lot of documentation to write! The entire point of this PR, of course, is to have better introspection and docstrings.
Fixes pandas-dev#9124 This PR adds plotting sub-methods like `df.plot.scatter()` as an alternative to using `df.plot(kind='scatter')`. I've added meaningful function signatures and documentation for a few of these methods, but I would greatly appreciate help to fill in the rest -- this is a lot of documentation to write! The entire point of this PR, of course, is to have better introspection and docstrings.
Currently, we use the
plot
for every possible kind of plot, and switch between them using thekind
keyword argument.From an API design and discoverability perspective, this seems less than ideal. If we had separate methods, standard introspection tools like IPython and autocomplete could help users figure out which arguments are applicable for which type of plot with less reliance on the documentation.
Another option is to make a
.plot
also an accessor, so we could havedf.plot.scatter
and so forth. But I suspect.plot_scatter
would be a bit more discoverable.The text was updated successfully, but these errors were encountered: