未验证 提交 844958df 编写于 作者: 飞龙 提交者: GitHub

Merge pull request #29 from melon-bun/master

seaborn.barplot
......@@ -180,4 +180,4 @@ boxplot和核密度估计的结合。一个传统的箱型图具有类似的API
```
![http://seaborn.pydata.org/_images/seaborn-boxenplot-8.png](img/ef97d95b2084af9b8636c2514545289d.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-boxenplot-8.png](img/ef97d95b2084af9b8636c2514545289d.jpg)
......@@ -4,109 +4,108 @@
seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, orient=None, color=None, palette=None, saturation=0.75, errcolor='.26', errwidth=None, capsize=None, dodge=True, ax=None, **kwargs)
```
Show point estimates and confidence intervals as rectangular bars.
条形图以矩形条的方式展示数据的点估值和置信区间
A bar plot represents an estimate of central tendency for a numeric variable with the height of each rectangle and provides some indication of the uncertainty around that estimate using error bars. Bar plots include 0 in the quantitative axis range, and they are a good choice when 0 is a meaningful value for the quantitative variable, and you want to make comparisons against it.
条形图用每个矩形的高度来表示数值变量的集中趋势的估计值,并提供误差条来显示估计值得不确定度。条形图的纵轴是从零开始的,这对于0值是有意义的情况是非常好的。
For datasets where 0 is not a meaningful value, a point plot will allow you to focus on differences between levels of one or more categorical variables.
对于数据集中的0值没有实际意义的情况,散点图可以让您专注于一个或多个分类变量之间的差异。
It is also important to keep in mind that a bar plot shows only the mean (or other estimator) value, but in many cases it may be more informative to show the distribution of values at each level of the categorical variables. In that case, other approaches such as a box or violin plot may be more appropriate.
要注意的是,条形图只显示平均值(或者其他的估计值),但是在大部分情况下,展示数值在不同分类变量上的分布会更有用。如果要表示出数据的分布,用箱型图或者小提琴图会更恰当。
Input data can be passed in a variety of formats, including:
输入数据的格式可以不同,包括:
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
* 以列表,numpy array或者pandas中的Series object 表示的向量。这些向量可以直接传入 `x`, `y`, 以及 `hue` 参数。
* 长表, x值,y值和色相变量决定了数据是如何绘制的。
* 宽表,每个列的数值都会被绘制出来.
* 数组或者列表的向量。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
大多数情况下,您可以使用numpy的对象或者python的对象,但是用pandas对象更好,因为相关的列名会被标注在图标上。 另外,为了控制绘图元素 您也可以可以用分类类型来组合不同的变量。
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
这个函数始终把一个变量当做分类变量,即使这个数据是数值类型或者日期类型,并且按照序数顺序绘制在相关的轴上。
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
详情请看[教程](../tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue`names of variables in `data` or vector data, optional
参数:`x, y, hue``data` 中的变量名词或者向量, optional
> Inputs for plotting long-form data. See examples for interpretation.
> 用于绘制long-form数据的变量名称.
`data`:DataFrame, array, or list of arrays, optional
`data`:DataFrame, 数组, 数组列表, optional
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
> 用于绘图的数据集。如果数据集有x和y,数据集会被认为是long-form,否则会被认为是wide-form。
`order, hue_order`lists of strings, optional
`order, hue_order`字符串列表, optional
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 绘制类别变量的顺序,如果没有,则从数据对象中推断绘图顺序。
`estimator`callable that maps vector -&gt; scalar, optional
`estimator`映射向量 -&gt; 标量, optional
> Statistical function to estimate within each categorical bin.
> 统计函数用于估计每个分类纸条中的值。.
`ci`:float or “sd” or None, optional
> Size of confidence intervals to draw around estimated values. If “sd”, skip bootstrapping and draw the standard deviation of the observations. If `None`, no bootstrapping will be performed, and error bars will not be drawn.
> 估计值周围的置信区间大小。如果输入的是 “sd”(标准差),会跳过bootstrapping的过程,只绘制数据的标准差。 如果输入是的是`None`, 不会执行botstrapping,而且错误条也不会绘制。
`n_boot`:int, optional
> Number of bootstrap iterations to use when computing confidence intervals.
> 计算置信区间需要的Boostrap迭代次数。
`units`:name of variable in `data` or vector data, optional
> Identifier of sampling units, which will be used to perform a multilevel bootstrap and account for repeated measures design.
> 采样单元的标识符,用于执行多级bootstrap并解释重复测量设计。
`orient`:“v” &#124; “h”, optional
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
> 绘图的方向(垂直或水平)。这通常是从输入变量的数据类型推断出来的,但是可以用来指定“分类”变量是数字还是宽格式数据。
`color`:matplotlib color, optional
> Color for all of the elements, or seed for a gradient palette.
> 作用于所有元素的颜色,或者渐变色的种子。
`palette`:palette name, list, or dict, optional
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
> 不同级别的 `hue` 变量的颜色。 颜色要能被 [`color_palette()`]解释(seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 或者一个能映射到matplotlib颜色的字典。
`saturation`:float, optional
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
`errcolor`:matplotlib color
> Color for the lines that represent the confidence interval.
> 表示置信区间的线的颜色。
`errwidth`:float, optional
> Thickness of error bar lines (and caps).
> 误差条的线的厚度。
`capsize`:float, optional
> Width of the “caps” on error bars.
> 误差条端部的宽度。
`dodge`:bool, optional
**dodge** : 布尔型, optional
> When hue nesting is used, whether elements should be shifted along the categorical axis.
`ax`:matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
> 指定一个Axes用于绘图,如果不指定,则使用当前的Axes。
`kwargs`:key, value mappings
> Other keyword arguments are passed through to `plt.bar` at draw time.
> 其他的关键词参数在绘图时通过 `plt.bar` 传入。
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
> 返回有图表绘制的Axes对象。
See also
Show the counts of observations in each categorical bin.Show point estimates and confidence intervals using scatterplot glyphs.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
显示每个分类bin中的观察计数。使用散点图图示符显示点估计和置信区间。将分类图与类相结合:<cite>FacetGrid</cite>.
Examples
Draw a set of vertical bar plots grouped by a categorical variable:
绘制一组按类别变量分组的垂直条形图:
```py
>>> import seaborn as sns
......@@ -118,7 +117,7 @@ Draw a set of vertical bar plots grouped by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-barplot-1.png](img/9d1addc98b6a35ef0376219c56e7b7fd.jpg)
Draw a set of vertical bars with nested grouping by a two variables:
绘制一组由两个变量嵌套分组的垂直条形图:
```py
>>> ax = sns.barplot(x="day", y="total_bill", hue="sex", data=tips)
......@@ -127,7 +126,7 @@ Draw a set of vertical bars with nested grouping by a two variables:
![http://seaborn.pydata.org/_images/seaborn-barplot-2.png](img/863249efe2403afa4fae2f2b6884d3bd.jpg)
Draw a set of horizontal bars:
绘制一组水平条形图:
```py
>>> ax = sns.barplot(x="tip", y="day", data=tips)
......@@ -136,7 +135,7 @@ Draw a set of horizontal bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-3.png](img/c3ea6265eaff0a4bfaec2966088cb66f.jpg)
Control bar order by passing an explicit order:
通过传入一个显式的顺序来控制条柱的顺序:
```py
>>> ax = sns.barplot(x="time", y="tip", data=tips,
......@@ -146,7 +145,7 @@ Control bar order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-barplot-4.png](img/9233554272a5e436f6ab85c97a65010c.jpg)
Use median as the estimate of central tendency:
用中值来评估数据的集中趋势:
```py
>>> from numpy import median
......@@ -156,7 +155,7 @@ Use median as the estimate of central tendency:
![http://seaborn.pydata.org/_images/seaborn-barplot-5.png](img/2622373fb99932aa42e45c3b151135be.jpg)
Show the standard error of the mean with the error bars:
用误差条显示平均值的标准误差:
```py
>>> ax = sns.barplot(x="day", y="tip", data=tips, ci=68)
......@@ -165,7 +164,7 @@ Show the standard error of the mean with the error bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-6.png](img/d1310bd7e87a8549d1f0b3a1479fc06d.jpg)
Show standard deviation of observations instead of a confidence interval:
展示数据的标准差:
```py
>>> ax = sns.barplot(x="day", y="tip", data=tips, ci="sd")
......@@ -174,7 +173,7 @@ Show standard deviation of observations instead of a confidence interval:
![http://seaborn.pydata.org/_images/seaborn-barplot-7.png](img/eeb77dac6d8f76d9f715476ce03773c5.jpg)
Add “caps” to the error bars:
给误差条增加“端点”:
```py
>>> ax = sns.barplot(x="day", y="tip", data=tips, capsize=.2)
......@@ -183,7 +182,7 @@ Add “caps” to the error bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-8.png](img/5a69e1058d9b8b4b5be6dc15d1bad130.jpg)
Use a different color palette for the bars:
使用一个不同的调色盘来绘制图案:
```py
>>> ax = sns.barplot("size", y="total_bill", data=tips,
......@@ -193,7 +192,7 @@ Use a different color palette for the bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-9.png](img/ef011fca38d3c55dde21ee8363e93e61.jpg)
Use `hue` without changing bar position or width:
在不改变条柱的位置或者宽度的前提下,使用 `hue` :
```py
>>> tips["weekend"] = tips["day"].isin(["Sat", "Sun"])
......@@ -204,7 +203,7 @@ Use `hue` without changing bar position or width:
![http://seaborn.pydata.org/_images/seaborn-barplot-10.png](img/d38d4ad12b16322a5ed00690bcbcd8b6.jpg)
Plot all bars in a single color:
用同一种颜色绘制所有条柱:
```py
>>> ax = sns.barplot("size", y="total_bill", data=tips,
......@@ -214,7 +213,7 @@ Plot all bars in a single color:
![http://seaborn.pydata.org/_images/seaborn-barplot-11.png](img/4922c693b75b7656b2f16f8fd2dd6509.jpg)
Use `plt.bar` keyword arguments to further change the aesthetic:
`plt.bar` 关键字参数进一步改变图表的样式:
```py
>>> ax = sns.barplot("day", "total_bill", data=tips,
......@@ -225,7 +224,7 @@ Use `plt.bar` keyword arguments to further change the aesthetic:
![http://seaborn.pydata.org/_images/seaborn-barplot-12.png](img/20114eb58ca40a3ccf0b20f14f426c83.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`barplot()`](#seaborn.barplot "seaborn.barplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 来结合 [`barplot()`](#seaborn.barplot "seaborn.barplot")[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). 这允许数据根据额外的类别变量分组。使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更安全, 因为它可以确保变量在不同的facet之间保持同步:
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......@@ -235,4 +234,4 @@ Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to com
```
![http://seaborn.pydata.org/_images/seaborn-barplot-13.png](img/a2d8b9c6867b1006b56e5508d5472c86.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-barplot-13.png](img/a2d8b9c6867b1006b56e5508d5472c86.jpg)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册