Show the counts of observations in each categorical bin using bars.
seaborn.countplot使用条形图显示每个类别中观测值的数量。
A count plot can be thought of as a histogram across a categorical, instead of quantitative, variable. The basic API and options are identical to those for [`barplot()`](seaborn.barplot.html#seaborn.barplot"seaborn.barplot"), so you can compare counts across nested variables.
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.
参数:`x, y, hue`:names of variables in `data` or vector data, optional
参数:`x, y, hue`:`data`或者向量数据中的变量名,可选
> Inputs for plotting long-form data. See examples for interpretation.
> 用于绘制长格式数据的输入。查看解释示例
`data`:DataFrame, array, or list of arrays, optional
`data`:DataFrame, 数组,或者包含数组的列表,可选
> 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'不存在,那么会将数据按宽格式进行处理,否则应当为长格式。
`order, hue_order`:lists of strings, optional
`order, hue_order`:包含字符串的列表,可选
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 分类层级绘制的顺序,否则层级会从数据对象中推测。
`orient`:“v” | “h”, optional
`orient`:“v” | “h”, 可选
> 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
`palette`:调色盘名称,列表或字典,可选
> 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.
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot"seaborn.catplot") to combine a [`countplot()`](#seaborn.countplot"seaborn.countplot") 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: