Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb59a06

Browse files
committed
Merge pull request #1757 from NelleV/MEP10
DOC improves documentation on the pyplot module and the bar method
2 parents 6e94330 + 4b3aced commit eb59a06

File tree

2 files changed

+169
-137
lines changed

2 files changed

+169
-137
lines changed

lib/matplotlib/axes.py

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,7 @@ def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
837837
'left': mspines.Spine.linear_spine(self, 'left'),
838838
'right': mspines.Spine.linear_spine(self, 'right'),
839839
'bottom': mspines.Spine.linear_spine(self, 'bottom'),
840-
'top': mspines.Spine.linear_spine(self, 'top'),
841-
}
840+
'top': mspines.Spine.linear_spine(self, 'top'), }
842841

843842
def cla(self):
844843
"""Clear the current axes."""
@@ -936,8 +935,7 @@ def cla(self):
936935
x=0.0, y=1.0, text='',
937936
fontproperties=props,
938937
verticalalignment='baseline',
939-
horizontalalignment='left',
940-
)
938+
horizontalalignment='left', )
941939
self._right_title = mtext.Text(
942940
x=1.0, y=1.0, text='',
943941
fontproperties=props,
@@ -4819,72 +4817,73 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
48194817
"""
48204818
Make a bar plot.
48214819
4822-
Call signature::
4823-
4824-
bar(left, height, width=0.8, bottom=0, **kwargs)
4825-
48264820
Make a bar plot with rectangles bounded by:
48274821
4828-
*left*, *left* + *width*, *bottom*, *bottom* + *height*
4822+
`left`, `left` + `width`, `bottom`, `bottom` + `height`
48294823
(left, right, bottom and top edges)
48304824
4831-
*left*, *height*, *width*, and *bottom* can be either scalars
4832-
or sequences
4825+
Parameters
4826+
----------
4827+
left : sequence of scalars
4828+
the x coordinates of the left sides of the bars
48334829
4834-
Return value is a list of
4835-
:class:`matplotlib.patches.Rectangle` instances.
4830+
height : sequence of scalars
4831+
the heights of the bars
48364832
4837-
Required arguments:
4833+
width : scalar or array-like, optional, default: 0.8
4834+
the width(s) of the bars
48384835
4839-
======== ===============================================
4840-
Argument Description
4841-
======== ===============================================
4842-
*left* the x coordinates of the left sides of the bars
4843-
*height* the heights of the bars
4844-
======== ===============================================
4836+
bottom : scalar or array-like, optional, default: None
4837+
the y coordinate(s) of the bars
48454838
4846-
Optional keyword arguments:
4839+
color : scalar or array-like, optional
4840+
the colors of the bars
48474841
4848-
=============== ==========================================
4849-
Keyword Description
4850-
=============== ==========================================
4851-
*width* the widths of the bars
4852-
*bottom* the y coordinates of the bottom edges of
4853-
the bars
4854-
*color* the colors of the bars
4855-
*edgecolor* the colors of the bar edges
4856-
*linewidth* width of bar edges; None means use default
4857-
linewidth; 0 means don't draw edges.
4858-
*xerr* if not None, will be used to generate
4859-
errorbars on the bar chart
4860-
*yerr* if not None, will be used to generate
4861-
errorbars on the bar chart
4862-
*ecolor* specifies the color of any errorbar
4863-
*capsize* (default 3) determines the length in
4864-
points of the error bar caps
4865-
*error_kw* dictionary of kwargs to be passed to
4866-
errorbar method. *ecolor* and *capsize*
4867-
may be specified here rather than as
4868-
independent kwargs.
4869-
*align* 'edge' (default) | 'center'
4870-
*orientation* 'vertical' | 'horizontal'
4871-
*log* [False|True] False (default) leaves the
4872-
orientation axis as-is; True sets it to
4873-
log scale
4874-
=============== ==========================================
4842+
edgecolor : scalar or array-like, optional
4843+
the colors of the bar edges
48754844
4876-
For vertical bars, *align* = 'edge' aligns bars by their left
4877-
edges in left, while *align* = 'center' interprets these
4878-
values as the *x* coordinates of the bar centers. For
4879-
horizontal bars, *align* = 'edge' aligns bars by their bottom
4880-
edges in bottom, while *align* = 'center' interprets these
4881-
values as the *y* coordinates of the bar centers.
4845+
linewidth : scalar or array-like, optional, default: None
4846+
width of bar edge(s). If None, use default
4847+
linewidth; If 0, don't draw edges.
48824848
4883-
The optional arguments *color*, *edgecolor*, *linewidth*,
4884-
*xerr*, and *yerr* can be either scalars or sequences of
4849+
xerr : scalar or array-like, optional, default: None
4850+
if not None, will be used to generate errorbar(s) on the bar chart
4851+
4852+
yerr :scalar or array-like, optional, default: None
4853+
if not None, will be used to generate errorbar(s) on the bar chart
4854+
4855+
ecolor : scalar or array-like, optional, default: None
4856+
specifies the color of errorbar(s)
4857+
4858+
capsize : integer, optional, default: 3
4859+
determines the length in points of the error bar caps
4860+
4861+
error_kw :
4862+
dictionary of kwargs to be passed to errorbar method. *ecolor* and
4863+
*capsize* may be specified here rather than as independent kwargs.
4864+
4865+
align : ['edge' | 'center'], optional, default: 'edge'
4866+
If `edge`, aligns bars by their left edges (for vertical bars) and
4867+
by their bottom edges (for horizontal bars). If `center`, interpret
4868+
the `left` argument as the coordinates of the centers of the bars.
4869+
4870+
orientation : 'vertical' | 'horizontal', optional, default: 'vertical'
4871+
The orientation of the bars.
4872+
4873+
log : boolean, optional, default: False
4874+
If true, sets the axis to be log scale
4875+
4876+
Returns
4877+
-------
4878+
:class:`matplotlib.patches.Rectangle` instances.
4879+
4880+
Note
4881+
----
4882+
The optional arguments `color`, `edgecolor`, `linewidth`,
4883+
`xerr`, and `yerr` can be either scalars or sequences of
48854884
length equal to the number of bars. This enables you to use
48864885
bar as the basis for stacked bar charts, or candlestick plots.
4887-
Detail: *xerr* and *yerr* are passed directly to
4886+
Detail: `xerr` and `yerr` are passed directly to
48884887
:meth:`errorbar`, so they can also have shape 2xN for
48894888
independent specification of lower and upper errors.
48904889

0 commit comments

Comments
 (0)