-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Improved the docstring of pandas.plotting._core.FramePlotMethods… #20157
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
Changes from 1 commit
d442214
a3f1982
3c48ca0
f9c2c3c
3abe837
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2738,18 +2738,81 @@ def bar(self, x=None, y=None, **kwds): | |
|
||
def barh(self, x=None, y=None, **kwds): | ||
""" | ||
Horizontal bar plot | ||
Make a horizontal bar plot. | ||
|
||
A horizontal bar plot is a plot that presents categorical data with | ||
rectangular bars with lengths proportional to the values that they | ||
represent. A bar plot shows comparisons among discrete categories. One | ||
axis of the plot shows the specific categories being compared, and the | ||
other axis represents a measured value. | ||
|
||
Parameters | ||
---------- | ||
x, y : label or position, optional | ||
Coordinates for each point. | ||
`**kwds` : optional | ||
x : label or position, optional | ||
Column to be used for categories. | ||
y : label or position, optional | ||
Columns to be plotted from the DataFrame. | ||
kwds : optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're updating the script. i think it's just
|
||
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`. | ||
|
||
Returns | ||
------- | ||
axes : matplotlib.AxesSubplot or np.array of them | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a dot at the end of the return sentence |
||
See Also | ||
-------- | ||
pandas.DataFrame.plot.bar: Vertical bar plot | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. End with a |
||
pandas.DataFrame.plot : Make plots of DataFrame using matplotlib. | ||
matplotlib.axes.Axes.bar : Plot a vertical bar plot using matplotlib. | ||
|
||
Examples | ||
-------- | ||
Basic example | ||
|
||
.. plot:: | ||
:context: close-figs | ||
|
||
>>> df = pd.DataFrame({'lab':['A','B','C'], 'val':[10,30,20]}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP8: space after commas |
||
>>> ax = df.plot.barh(x='lab',y='val') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space after |
||
|
||
Plot a whole DataFrame to a horizontal bar plot | ||
|
||
.. plot:: | ||
:context: close-figs | ||
|
||
>>> speed = [0.1, 17.5, 40, 48, 52, 69, 88] | ||
>>> lifespan = [2, 8, 70, 1.5, 25, 12, 28] | ||
>>> index = ['snail', 'pig', 'elephant', | ||
... 'rabbit', 'giraffe', 'coyote', 'horse'] | ||
>>> df = pd.DataFrame({'speed': speed, | ||
... 'lifespan': lifespan}, index=index) | ||
>>> ax = df.plot.barh() | ||
|
||
Plot a column of the DataFrame to a horizontal bar plot | ||
|
||
.. plot:: | ||
:context: close-figs | ||
|
||
>>> speed = [0.1, 17.5, 40, 48, 52, 69, 88] | ||
>>> lifespan = [2, 8, 70, 1.5, 25, 12, 28] | ||
>>> index = ['snail', 'pig', 'elephant', | ||
... 'rabbit', 'giraffe', 'coyote', 'horse'] | ||
>>> df = pd.DataFrame({'speed': speed, | ||
... 'lifespan': lifespan}, index=index) | ||
>>> ax = df.plot.barh(y='speed') | ||
|
||
Plot DataFrame versus the desired column | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DataFrame -> DataFrame's index? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you provide more information on what do you mean? "Plot DataFrame versus the desired column", this means to plot the whole dataframe vs the column of the dataframe that you want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what I meant there, sorry :) |
||
|
||
.. plot:: | ||
:context: close-figs | ||
|
||
>>> speed = [0.1, 17.5, 40, 48, 52, 69, 88] | ||
>>> lifespan = [2, 8, 70, 1.5, 25, 12, 28] | ||
>>> index = ['snail', 'pig', 'elephant', | ||
... 'rabbit', 'giraffe', 'coyote', 'horse'] | ||
>>> df = pd.DataFrame({'speed': speed, | ||
... 'lifespan': lifespan}, index=index) | ||
>>> ax = df.plot.barh(x='lifespan') | ||
""" | ||
return self(kind='barh', x=x, y=y, **kwds) | ||
|
||
|
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.
Can you describe the defaults. For
x
I think it's the DataFrame's index. Fory
I think it's all numeric columns.