未验证 提交 616f20eb 编写于 作者: A alohahahaha 提交者: GitHub

Update 5.md

上级 7643475a
......@@ -152,9 +152,9 @@ sns.jointplot(x="x", y="y", data=df);
![http://seaborn.pydata.org/_images/distributions_28_0.png](img/66ba868aeef60b82d90c872e188217ed.jpg)
### 六角形箱(Hexbin)图
### 六边形“桶”(Hexbin)图
The bivariate analogue of a histogram is known as a “hexbin” plot, because it shows the counts of observations that fall within hexagonal bins. This plot works best with relatively large datasets. It’s available through the matplotlib `plt.hexbin` function and as a style in [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot"). It looks best with a white background:
类似于单变量的直方图,用于描绘二元变量关系的图称为 “hexbin” 图,因为它显示了落入六边形“桶”内的观察计数。 此图对于相对较大的数据集最有效。它可以通过调用matplotlib中的 `plt.hexbin`函数获得并且在[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")作为一种样式。当使用白色作为背景色时效果最佳。
```py
x, y = np.random.multivariate_normal(mean, cov, 1000).T
......@@ -165,9 +165,9 @@ with sns.axes_style("white"):
![http://seaborn.pydata.org/_images/distributions_30_0.png](img/621cac508b507f43ba50f91290aea5fd.jpg)
### Kernel density estimation
### 核密度估计
It is also possible to use the kernel density estimation procedure described above to visualize a bivariate distribution. In seaborn, this kind of plot is shown with a contour plot and is available as a style in [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot"):
也可以使用上面描述的核密度估计过程来可视化二元分布。在seaborn中,这种图用等高线图表示, 在[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")中被当作一种样式:
```py
sns.jointplot(x="x", y="y", data=df, kind="kde");
......@@ -176,7 +176,7 @@ sns.jointplot(x="x", y="y", data=df, kind="kde");
![http://seaborn.pydata.org/_images/distributions_32_0.png](img/3fa9b8716f00e81aa6ca6864cb110e2b.jpg)
You can also draw a two-dimensional kernel density plot with the [`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot") function. This allows you to draw this kind of plot onto a specific (and possibly already existing) matplotlib axes, whereas the [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") function manages its own figure:
您还可以使用[`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")函数绘制二维核密度图。这允许您在一个特定的(可能已经存在的)matplotlib轴上绘制这种图,而 [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") 函数能够管理它自己的图:
```py
f, ax = plt.subplots(figsize=(6, 6))
......@@ -188,7 +188,7 @@ sns.rugplot(df.y, vertical=True, ax=ax);
![http://seaborn.pydata.org/_images/distributions_34_0.png](img/5bbf1afea90de1dcab11584fb0169efe.jpg)
If you wish to show the bivariate density more continuously, you can simply increase the number of contour levels:
如果希望更连续地显示双变量密度,可以简单地增加轮廓层的数量:
```py
f, ax = plt.subplots(figsize=(6, 6))
......@@ -199,7 +199,7 @@ sns.kdeplot(df.x, df.y, cmap=cmap, n_levels=60, shade=True);
![http://seaborn.pydata.org/_images/distributions_36_0.png](img/fd8b7fa16dccb291fe1a2148a45e3eba.jpg)
The [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") function uses a [`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") to manage the figure. For more flexibility, you may want to draw your figure by using [`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") directly. [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") returns the [`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") object after plotting, which you can use to add more layers or to tweak other aspects of the visualization:
[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")函数使用[`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")来管理图形。为了获得更大的灵活性,您可能想直接使用[`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")来绘制图形。[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")在绘图后返回[`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")对象,您可以使用它添加更多图层或调整可视化的其他方面:
```py
g = sns.jointplot(x="x", y="y", data=df, kind="kde", color="m")
......@@ -211,10 +211,9 @@ g.set_axis_labels("$X$", "$Y$");
![http://seaborn.pydata.org/_images/distributions_38_0.png](img/aeaafccce597b72105feb6cf712b0ca2.jpg)
## Visualizing pairwise relationships in a dataset
To plot multiple pairwise bivariate distributions in a dataset, you can use the [`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot") function. This creates a matrix of axes and shows the relationship for each pair of columns in a DataFrame. by default, it also draws the univariate distribution of each variable on the diagonal Axes:
## 可视化数据集中的成对关系
要在数据集中绘制多个成对的双变量分布,您可以使用[`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot")函数。 这将创建一个轴矩阵并显示DataFrame中每对列的关系,默认情况下,它还绘制对角轴上每个变量的单变量分布:
```py
iris = sns.load_dataset("iris")
sns.pairplot(iris);
......@@ -223,7 +222,7 @@ sns.pairplot(iris);
![http://seaborn.pydata.org/_images/distributions_40_0.png](img/bea67bf34fcd01d7b6f454ae5f563460.jpg)
Much like the relationship between [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") and [`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid"), the [`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot") function is built on top of a [`PairGrid`](../generated/seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") object, which can be used directly for more flexibility:
与[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")和[`JointGrid`](../generated/seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")之间的关系非常类似, [`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot")函数构建在[`PairGrid`](../generated/seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")对象之上, 可以直接使用它来获得更大的灵活性:
```py
g = sns.PairGrid(iris)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册