未验证 提交 6ae0fc07 编写于 作者: 飞龙 提交者: GitHub

Merge pull request #26 from LIJIANcoder97/master

Update 15.md 翻译
......@@ -4,85 +4,84 @@
seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)
```
Draw a categorical scatterplot with non-overlapping points.
绘制具有非重叠点的分类散点图。
This function is similar to [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot"), but the points are adjusted (only along the categorical axis) so that they don’t overlap. This gives a better representation of the distribution of values, but it does not scale well to large numbers of observations. This style of plot is sometimes called a “beeswarm”.
此功能类似于 [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot"),,但调整点(仅沿分类轴),以便它们不重叠。 这样可以更好地表示值的分布,但不能很好地扩展到大量观察值。这种情节有时被称为“诅咒”
A swarm plot can be drawn on its own, but it is also a good complement to a box or violin plot in cases where you want to show all observations along with some representation of the underlying distribution.
一个群体图可以单独绘制,但如果你想要显示所有观察结果以及底层分布的一些表示,它也是一个盒子或小提琴图的良好补充。
Arranging the points properly requires an accurate transformation between data and point coordinates. This means that non-default axis limits must be set _before_ drawing the plot.
正确排列点需要在数据和点坐标之间进行精确转换。这意味着必须在绘制绘图之前设置非默认轴限制。
Input data can be passed in a variety of formats, including:
输入数据可以以多种格式传递,包括:
* 表示为列表,numpy arrays或pandas Series objects直接传递给`x``y`和/或`hue`参数。
* “长格式” DataFrame, `x``y``hue`变量将决定数据的绘制方式
* “宽格式”DataFrame,用于绘制每个数字列。
* 一个数组或向量列表。
* 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或Python对象,但最好使用pandas对象,因为关联的名称将用于注释轴。此外,您可以使用分类类型来分组变量来控制绘图元素的顺序。
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.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型也是如此
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.
有关更多信息,请参阅[教程](../tutorial/categorical.html#categorical-tutorial)
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
参数:`x, y, hue``数据`或矢量数据中的变量名称,可选
参数:`x, y, hue`:names of variables in `data` or vector data, optional
> 用于绘制长格式数据的输入。查看解释示例。
> Inputs for plotting long-form data. See examples for interpretation.
`data`:DataFrame, array, or 或数组列表, 可选
`data`:DataFrame, array, or list of arrays, optional
> 用于绘图的数据集。 如果 `x` 和 `y` 是不存在的, 会被解释成 wide-form. 否则会被解释成 long-form.
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
`order, hue_order`:字符串列表,可选
`order, hue_order`:lists of strings, optional
> 命令绘制分类级别,否则从数据对象推断级别。
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
`dodge`:布尔,可选
`dodge`:bool, optional
> 使用`hue`嵌套时,将其设置为`True`将沿着分类轴分离不同色调级别的条带。 否则,每个级别的点将绘制在一个群中。
> When using `hue` nesting, setting this to `True` will separate the strips for different hue levels along the categorical axis. Otherwise, the points for each level will be plotted in one swarm.
`orient`:“v” | “h”, 可选
`orient`:“v” | “h”, optional
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> 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, 可选
`color`:matplotlib color, optional
> 所有元素的颜色,或渐变调色板的种子。
> Color for all of the elements, or seed for a gradient palette.
`palette`:调色板名称, list, or dict, 可选
`palette`:palette name, list, or dict, optional
> 用于`hue`变量的不同级别的颜色。应该是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"),可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> 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.
`size`:float, 可选
`size`:float, optional
> 标记的直径,以点为单位。 (尽管`plt.scatter`用于绘制点,但此处的`size`参数采用“普通”标记大小而不是大小^ 2,如`plt.scatter`。
> Diameter of the markers, in points. (Although `plt.scatter` is used to draw the points, the `size` argument here takes a “normal” markersize and not size^2 like `plt.scatter`.
`edgecolor`:matplotlib color, “灰色”是特殊的,可选
`edgecolor`:matplotlib color, “gray” is special-cased, optional
> 每个点周围线条的颜色。如果传递`"gray"`,则亮度由用于点体的调色板决定。
> Color of the lines around each point. If you pass `"gray"`, the brightness is determined by the color palette used for the body of the points.
`linewidth`:float, 可选
`linewidth`:float, optional
> 构图元素的灰线宽度。
> Width of the gray lines that frame the plot elements.
`ax`:matplotlib Axes, 可选
`ax`:matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
> Axes对象将绘图绘制到,否则使用当前轴。
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
> 返回Axes对象,并在其上绘制绘图。
See also
参看
A traditional box-and-whisker plot with a similar API.A combination of boxplot and kernel density estimation.A scatterplot where one variable is categorical. Can be used in conjunction with other plots to show each observation.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
带有类似API的传统盒须图。框图和核密度估计的组合。散点图,其中一个变量是分类的。可以与其他图一起使用以显示每个观察结果。使用类组合分类图:<cite>FacetGrid</cite>
Examples
Draw a single horizontal swarm plot:
绘制单个水平群图:
```py
>>> import seaborn as sns
......@@ -94,7 +93,7 @@ Draw a single horizontal swarm plot:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-1.png](img/900c725fafc0f5e475a98f52f4ed7d04.jpg)
Group the swarms by a categorical variable:
通过分类变量对群组进行分组:
```py
>>> ax = sns.swarmplot(x="day", y="total_bill", data=tips)
......@@ -103,7 +102,7 @@ Group the swarms by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-2.png](img/414037bdbfc9b79cf5f12a30645f7301.jpg)
Draw horizontal swarms:
绘制水平群:
```py
>>> ax = sns.swarmplot(x="total_bill", y="day", data=tips)
......@@ -112,7 +111,7 @@ Draw horizontal swarms:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-3.png](img/b03c6dbcd2d2f71c2e5eafa99b46d96b.jpg)
Color the points using a second categorical variable:
使用第二个分类变量为点着色:
```py
>>> ax = sns.swarmplot(x="day", y="total_bill", hue="sex", data=tips)
......@@ -121,7 +120,7 @@ Color the points using a second categorical variable:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-4.png](img/12d5e5950bf28b7027b28766bc41989f.jpg)
Split each level of the `hue` variable along the categorical axis:
沿着分类轴拆分 `hue` 变量的每个级别:
```py
>>> ax = sns.swarmplot(x="day", y="total_bill", hue="smoker",
......@@ -131,7 +130,7 @@ Split each level of the `hue` variable along the categorical axis:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-5.png](img/6f9585fcbe42e72521292b80b0fdc97a.jpg)
Control swarm order by passing an explicit order:
通过传递显式顺序来控制swarm顺序:
```py
>>> ax = sns.swarmplot(x="time", y="tip", data=tips,
......@@ -141,7 +140,7 @@ Control swarm order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-6.png](img/73bbf8c6208a6e1c0dda89091dd509a4.jpg)
Plot using larger points:
绘制使用更大的点
```py
>>> ax = sns.swarmplot(x="time", y="tip", data=tips, size=6)
......@@ -150,7 +149,7 @@ Plot using larger points:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-7.png](img/34aa97c61dd6f6176fa2256880526439.jpg)
Draw swarms of observations on top of a box plot:
在箱形图上绘制大量观察结果:
```py
>>> ax = sns.boxplot(x="tip", y="day", data=tips, whis=np.inf)
......@@ -160,7 +159,7 @@ Draw swarms of observations on top of a box plot:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-8.png](img/d992e6312a3ed98025ad0913dbc46228.jpg)
Draw swarms of observations on top of a violin plot:
在小提琴图的顶部画出大量的观察结果:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", data=tips, inner=None)
......@@ -171,7 +170,7 @@ Draw swarms of observations on top of a violin plot:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-9.png](img/735aa7eaadb9afb7a47a2d079b28a10b.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`swarmplot()`](#seaborn.swarmplot "seaborn.swarmplot") 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") 去组合 [`swarmplot()`](#seaborn.swarmplot "seaborn.swarmplot")[`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",
......@@ -181,4 +180,4 @@ Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to com
```
![http://seaborn.pydata.org/_images/seaborn-swarmplot-10.png](img/7c1bc4a2871b9e0dbe2c23ed05fcae1b.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-swarmplot-10.png](img/7c1bc4a2871b9e0dbe2c23ed05fcae1b.jpg)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册