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.
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.
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.
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.
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 绘制类别变量的顺序,如果没有,则从数据对象中推断绘图顺序。
`estimator`:callable that maps vector -> scalar, optional
`estimator`:映射向量 -> 标量, 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.
> 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” | “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 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.
> 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>.
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: