Skip to content

ENH: Improve plotting types #278

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 5 commits into from
Sep 8, 2022
Merged

ENH: Improve plotting types #278

merged 5 commits into from
Sep 8, 2022

Conversation

bashtage
Copy link
Contributor

@bashtage bashtage commented Sep 7, 2022

Add types for many inputs
Clean out non-public functions

  • Tests added: Please use assert_type() to assert the type of any return value

Add types for many inputs
Clean out non-public functions
Add tests
Correct types
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good in the tests to have one test where we test all the kwargs documented in DataFrame.plot()

Add covered types in docs
Add tests
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of the keywords in DataFrame.plot() can also be passed to things like DataFrame.plot.line(), etc. So I think we should copy the keywords you included in __call__() over to each of the individual functions. E.g., the following is valid:

foo = pd.DataFrame({"x":[i for i in range(10)], "y":[i*i for i in range(10)]})
foo.plot.line("x", "y", figsize=(3,3))

You don't have to test each one.

@bashtage
Copy link
Contributor Author

bashtage commented Sep 8, 2022

I think all of the keywords in DataFrame.plot() can also be passed to things like DataFrame.plot.line(), etc. So I think we should copy the keywords you included in __call__() over to each of the individual functions. E.g., the following is valid:

I'm hesitant to do this since not all keywords are accepted by all plot types and some, even if accepted, have no effect. For example, positions and colorbar can't be used with line. IMO, the general plot() function is a mess of a function but is there for quick analysis.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Sep 8, 2022

I'm hesitant to do this since not all keywords are accepted by all plot types and some, even if accepted, have no effect. For example, positions and colorbar can't be used with line. IMO, the general plot() function is a mess of a function but is there for quick analysis.

Fair point. It's not clear to me if people would do df.plot(x="x", y="y", kind="line", figsize=(5, 5)) or df.plot.line(x="x", y="y", figsize=(5, 5)), although the examples at https://pandas.pydata.org/docs/user_guide/visualization.html?highlight=plotting seem to show the latter usage. Having said that, I think many of the accepted keywords listed in DataFrame.plot() in the docs are potentially specific to the chosen backend, so getting that right from a typing perspective would be a nightmare.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @bashtage

@Dr-Irv Dr-Irv merged commit 096b9b8 into pandas-dev:main Sep 8, 2022
@bashtage bashtage deleted the plotting branch September 15, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants