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.
可以通过多种格式传入数据,包括:
Input data can be passed in a variety of formats, including:
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.
> 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`:matplotlib color, optional
> 所有元素的颜色,或者渐变调色盘的种子。
> Color for all of the elements, or seed for a gradient 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.
`dodge`: bool, 可选
`dodge`:bool, optional
> 当使用色调嵌套时,决定是否沿着类别轴对元素进行移位。
> When hue nesting is used, whether elements should be shifted along the categorical axis.
`ax`: matplotlib轴,可选
`ax`:matplotlib Axes, optional
> 绘制图像的轴对象,不指定时使用当前轴。
> Axes object to draw the plot onto, otherwise uses the current Axes.
`kwargs`: 键值映射
`kwargs`:key, value mappings
> 其他关键字参数会被传递给`plt.bar`.
> Other keyword arguments are passed to `plt.bar`.
返回值:`ax`: matplotlib轴
返回值:`ax`:matplotlib Axes
> 返回带有绘图的轴对象。
> Returns the Axes object with the plot drawn onto it.
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: