Skip to content

DOC Use plot.<kind> instead of plot(kind=<kind>) GH11043 #11303

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

Closed
wants to merge 4 commits into from

Conversation

Moisan
Copy link
Contributor

@Moisan Moisan commented Oct 12, 2015

closes #11043

I modified the visualization documentation to use plot. instead of plot(kind=) in the examples as explained by issue 11043.


To plot multiple column groups in a single axes, repeat ``plot`` method specifying target ``ax``.
It is recommended to specify ``color`` and ``label`` keywords to distinguish each groups.

.. ipython:: python

ax = df.plot(kind='scatter', x='a', y='b',
ax = df.plot.scatter(x='a', y='b',
color='DarkBlue', label='Group 1');
Copy link
Member

Choose a reason for hiding this comment

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

fix the indentation to align with ( on the line above

@shoyer
Copy link
Member

shoyer commented Oct 12, 2015

Thanks for putting this together! Looks pretty good to me, modulo a few nit-picks.

@jreback jreback added this to the 0.17.1 milestone Oct 12, 2015
@jreback
Copy link
Contributor

jreback commented Oct 12, 2015

can we leave a small example that uses the old syntax (and maybe a note about the usefulness of having the accessor).

@jreback
Copy link
Contributor

jreback commented Oct 25, 2015

any comments @jorisvandenbossche @shoyer @sinhrks

.. versionadded:: 0.15.0

Histogram can be drawn specifying ``kind='hist'``.
Histogram can be drawn by using the ``plot(kind='hist')`` method.
Copy link
Member

Choose a reason for hiding this comment

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

plot.hist ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

plot(kind='hist') has been added in version 0.15.0 but not plot.hist. I kept the previous method to point what was new with that version. With new the general description at the top of the document, I felt that plot(kind='hist') was clearer than kind='hist'.

Copy link
Contributor

Choose a reason for hiding this comment

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

i would remove the 0.15.0 comment as you have the 0.17.0 tag here with the new way

@jreback
Copy link
Contributor

jreback commented Nov 13, 2015

@Moisan can you squash


.. versionadded:: 0.17.0

:meth:`DataFrame.plot.box` and :meth:`Series.plot.box` can now be used to draw boxplot.

.. versionadded:: 0.15.0
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, you can remove the original tag

@jreback
Copy link
Contributor

jreback commented Nov 13, 2015

ok I see that we are adding versionadded tags for the API change in 0.17.0, but IIRC that is at the top of the docs?

but its nice to see when the method is added, so reversing some of my comments from above :)

let's leave the original version added tags (but show them with .plot.* rather than .plot(kind=....)

I know a bit of a a misnomer here, but it is overall much cleaner i think.

@jorisvandenbossche
Copy link
Member

I am personally a bit hesitant to change this in the full plotting docs, because it is a reality that a lot of people are not using the latest pandas. Seeing these docs will lead to errors for them and potential confusion.
(this is of course also true for other new things in the docs, but most of the time it are not full pages)
Keeping the original syntax (kind='') in the main examples on this pages would ensure the docs pages it more cross-version compatible.

@jreback
Copy link
Contributor

jreback commented Nov 13, 2015

How about change the actual examples and put a ::note right above (each one)? , this encourages change, but provides the original in an easy way?

@Moisan
Copy link
Contributor Author

Moisan commented Nov 17, 2015

So we would let the original examples in a ::note or would we add a few sentences about the fact that before 0.17.0 one should use kind=''?

In short, what do I need to do exactly to make it in the release?

@jreback
Copy link
Contributor

jreback commented Nov 17, 2015

@jorisvandenbossche @shoyer what are thoughts here?

@jreback jreback modified the milestones: Next Major Release, 0.17.1 Nov 18, 2015
@jreback
Copy link
Contributor

jreback commented Dec 11, 2015

@shoyer thoughts here

@shoyer
Copy link
Member

shoyer commented Dec 11, 2015

I think we should update the docs to use the new syntax. It's not hard to find old versions of docs on Google, and this really is a cleaner way to do things.

@jreback
Copy link
Contributor

jreback commented Dec 11, 2015

sounds good to me. @Moisan let's do that (you can still leave the versionadded tags for when that actual graphing feature came into pandas I guess).

but don't add tags for the overall syntax change. I think their is already a note about that at the top anyhow.

@jreback
Copy link
Contributor

jreback commented Jan 6, 2016

@Moisan can you update

@Moisan
Copy link
Contributor Author

Moisan commented Jan 6, 2016

I thought my last commit fixed these points. Is there something I missed?

@jreback
Copy link
Contributor

jreback commented Jan 6, 2016

@shoyer can you review

plt.figure();

@savefig bar_plot_ex.png
df.ix[5].plot(kind='bar'); plt.axhline(0, color='k')
Copy link
Contributor

Choose a reason for hiding this comment

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

you changed there rest, might as well change this one too (to use .plot.bar())

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably good to keep this one, since right after we say you can alternatively use the new .plot.<kind> method.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok sure

@jreback jreback modified the milestones: 0.18.0, Next Major Release Jan 30, 2016
@jreback
Copy link
Contributor

jreback commented Jan 30, 2016

@TomAugspurger
Copy link
Contributor

@jorisvandenbossche are you OK with this? We have the old version of the docs linked on the main page, and the error should be pretty discoverable since we have the versionadded tag right before discussing the .plot.kind way. I'm +1

@jreback
Copy link
Contributor

jreback commented Feb 9, 2016

@jorisvandenbossche ?

@jreback jreback closed this in 2ce897f Feb 12, 2016
@jreback
Copy link
Contributor

jreback commented Feb 12, 2016

thanks @Moisan

docs will be built in a few hours, pls review: http://pandas-docs.github.io/pandas-docs-travis/

and if necessary issue a follow up

@Moisan
Copy link
Contributor Author

Moisan commented Feb 12, 2016

I reviewed the updated docs and everything seems fine. 👍

@jorisvandenbossche
Copy link
Member

I also looked at the docs, and I think there is one minor thing that can be improved: the refs to the plotting methods.
To illustrate, the docs say now in the bar plots section: "Calling a DataFrame’s bar() method produces a multiple bar plot:" (from the code Calling a DataFrame's :meth:~DataFrame.plot.bar method produces a multiple). So the rendered version implies that there is a bar() method on DataFrame (because the DataFrame.plot part is left out by sphinx), which is of course not the case.

Possible solution is to leave out the ~: Calling a DataFrame's :meth:DataFrame.plot.bar method ... would give "Calling a DataFrame’s DataFrame.plot.bar() method" (but it can then be rephrased a bit to not have the double DataFrame).
Alternative solution is to provide the text that sphinx should display: Calling a DataFrame's :meth:plot.bar() <DataFrame.plot.bar> method ... would give "Calling a DataFrame’s plot.bar() method"

@Moisan Would you be interested in a follow-up PR?

@jorisvandenbossche
Copy link
Member

On a closer look, the example I gave is actually the only occurence of that problem :-)
For all the rest you already used the 'absolute' reference without ~!

I changed this one occurence in another PR: #12326

@Moisan Moisan deleted the remove_plot_kind branch February 15, 2016 19:21
@Moisan
Copy link
Contributor Author

Moisan commented Feb 15, 2016

Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: consider updating visualization.rst to use plot submethods rather than kind
6 participants