提交 a2207fc2 编写于 作者: W wizardforcel
......@@ -10,12 +10,6 @@
* [ApacheCN 机器学习交流群 629470233](http://shang.qq.com/wpa/qunwpa?idkey=30e5f1123a79867570f665aa3a483ca404b1c3f77737bc01ec520ed5f078ddef)
* [ApacheCN 学习资源](http://www.apachecn.org/)
## 贡献指南
项目当前处于翻译阶段,请查看[贡献指南](CONTRIBUTING.md),并在[整体进度](https://github.com/apachecn/seaborn-doc-zh/issues/1)中领取任务。
> 请您勇敢地去翻译和改进翻译。虽然我们追求卓越,但我们并不要求您做到十全十美,因此请不要担心因为翻译上犯错——在大部分情况下,我们的服务器已经记录所有的翻译,因此您不必担心会因为您的失误遭到无法挽回的破坏。(改编自维基百科)
## 联系方式
### 负责人
......@@ -24,7 +18,6 @@
### 其他
* 认领翻译和项目进度-地址: <https://github.com/apachecn/seaborn-doc-zh/issues/1>
* 在我们的 [apachecn/seaborn-doc-zh](https://github.com/apachecn/seaborn-doc-zh) github 上提 issue.
* 发邮件到 Email: `apachecn@163.com`.
* 在我们的 [组织学习交流群](http://www.apachecn.org/organization/348.html) 中联系群主/管理员即可.
......
+ [seaborn 0.9 中文文档](README.md)
+ [An introduction to seaborn](docs/1.md)
+ [Installing and getting started](docs/2.md)
+ [Visualizing statistical relationships](docs/3.md)
+ [Plotting with categorical data](docs/4.md)
+ [Visualizing the distribution of a dataset](docs/5.md)
+ [Visualizing linear relationships](docs/6.md)
+ [Building structured multi-plot grids](docs/7.md)
+ [Controlling figure aesthetics](docs/8.md)
+ [Choosing color palettes](docs/9.md)
+ [Seaborn 简介](docs/1.md)
+ [安装和入门](docs/2.md)
+ [可视化统计关系](docs/3.md)
+ [可视化分类数据](docs/4.md)
+ [可视化数据集的分布](docs/5.md)
+ [线性关系可视化](docs/6.md)
+ [构建结构化多图网格](docs/7.md)
+ [控制图像的美学样式](docs/8.md)
+ [选择调色板](docs/9.md)
+ [seaborn.relplot](docs/10.md)
+ [seaborn.scatterplot](docs/11.md)
+ [seaborn.lineplot](docs/12.md)
......
......@@ -6,14 +6,14 @@ Seaborn 是一个基于 [matplotlib](https://matplotlib.org/) 且数据结构与
这里列出了一些 seaborn 的功能:
* 计算[多变量](examples/faceted_lineplot.html#faceted-lineplot)[关系](examples/scatter_bubbles.html#scatter-bubbles)的面向数据集接口
* 可视化类别变量的[观测](examples/jitter_stripplot.html#jitter-stripplot)[统计](examples/pointplot_anova.html#pointplot-anova)
* 可视化[单变量](examples/distplot_options.html#distplot-options)[多变量](examples/joint_kde.html#joint-kde)分布并与其子数据集[比较](examples/horizontal_boxplot.html#horizontal-boxplot)
* 控制[线性回归](examples/anscombes_quartet.html#anscombes-quartet)的不同[因变量](examples/logistic_regression.html#logistic-regression)并进行参数估计与作图
* 对复杂数据进行易行的整体[结构](examples/scatterplot_matrix.html#scatterplot-matrix)可视化
*[多表统计图](examples/faceted_histogram.html#faceted-histogram)的制作高度抽象并简化可视化过程
* 提供多个内建[主题](tutorial/aesthetics.html#aesthetics-tutorial)渲染 matplotlib 的图像样式
* 提供[调色板](tutorial/color_palettes.html#palette-tutorial)工具生动再现数据
* 计算[多变量](http://seaborn.pydata.org/examples/faceted_lineplot.html#faceted-lineplot)[关系](http://seaborn.pydata.org/examples/scatter_bubbles.html#scatter-bubbles)的面向数据集接口
* 可视化类别变量的[观测](http://seaborn.pydata.org/examples/jitter_stripplot.html#jitter-stripplot)[统计](http://seaborn.pydata.org/examples/pointplot_anova.html#pointplot-anova)
* 可视化[单变量](http://seaborn.pydata.org/examples/distplot_options.html#distplot-options)[多变量](http://seaborn.pydata.org/examples/joint_kde.html#joint-kde)分布并与其子数据集[比较](http://seaborn.pydata.org/examples/horizontal_boxplot.html#horizontal-boxplot)
* 控制[线性回归](http://seaborn.pydata.org/examples/anscombes_quartet.html#anscombes-quartet)的不同[因变量](http://seaborn.pydata.org/examples/logistic_regression.html#logistic-regression)并进行参数估计与作图
* 对复杂数据进行易行的整体[结构](http://seaborn.pydata.org/examples/scatterplot_matrix.html#scatterplot-matrix)可视化
*[多表统计图](http://seaborn.pydata.org/examples/faceted_histogram.html#faceted-histogram)的制作高度抽象并简化可视化过程
* 提供多个内建[主题](http://seaborn.pydata.org/tutorial/aesthetics.html#aesthetics-tutorial)渲染 matplotlib 的图像样式
* 提供[调色板](http://seaborn.pydata.org/tutorial/color_palettes.html#palette-tutorial)工具生动再现数据
Seaborn 框架旨在以数据可视化为中心来挖掘与理解数据。它提供的面向数据集制图函数主要是对行列索引和数组的操作,包含对整个数据集进行内部的语义映射与统计整合,以此生成富于信息的图表。
......@@ -49,7 +49,7 @@ sns.set()
```
这里改变了 [matplotlib rcParam 系统](https://matplotlib.org/users/customizing.html) 所以会影响所有 matplotlib 图像的显示,即使你没有显式的调用 seaborn 修改这些参数。除了缺省的主题,我们提供一些[其他选项](tutorial/aesthetics.html#aesthetics-tutorial),你可以独立的控制图片风格与尺寸来将他们迅速应用到演讲当中(例如,在演讲投影中使用一个拥有可阅读字体的图表)。如果你倾向于使用默认 matplotlib 主题或者其他的内置样式,你可以跳过这一部分,只使用 seaborn 提供的制图函数。
这里改变了 [matplotlib rcParam 系统](https://matplotlib.org/users/customizing.html) 所以会影响所有 matplotlib 图像的显示,即使你没有显式的调用 seaborn 修改这些参数。除了缺省的主题,我们提供一些[其他选项](http://seaborn.pydata.org/tutorial/aesthetics.html#aesthetics-tutorial),你可以独立的控制图片风格与尺寸来将他们迅速应用到演讲当中(例如,在演讲投影中使用一个拥有可阅读字体的图表)。如果你倾向于使用默认 matplotlib 主题或者其他的内置样式,你可以跳过这一部分,只使用 seaborn 提供的制图函数。
1. 装载数据集
......@@ -225,7 +225,7 @@ sns.relplot(x="total_bill", y="tip", col="time",
![http://seaborn.pydata.org/_images/introduction_31_0.png](img/4263c8446521fa44bcb4c6f2bdec4bad.jpg)
如果要仅针对图像设计,所有的 seaborn 函数都接受一系列的可选参数来改变默认的语义映射,比如颜色。(对颜色的恰当选择在数据可视化中非常关键,seaborn 提供了[附加支持](tutorial/color_palettes.html#palette-tutorial) 来引导调色板的使用)。
如果要仅针对图像设计,所有的 seaborn 函数都接受一系列的可选参数来改变默认的语义映射,比如颜色。(对颜色的恰当选择在数据可视化中非常关键,seaborn 提供了[附加支持]http://seaborn.pydata.org/tutorial/color_palettes.html#palette-tutorial) 来引导调色板的使用)。
最后,当 seaborn 的函数与 matploblib 函数具有显然一致性时(例如 [`scatterplot()`](generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")`plt.scatter`),多余的参数会被直接传给 matploblib 层:
......@@ -313,4 +313,4 @@ fmri.head()
## 下一步
继续往下看,你有多个选择。比如你可能想去[安装 seaborn](installing.html#installing)。然后你可以看看[制图样例](examples/index.html#example-gallery)来了解 seaborn 到底可以绘制什么样的图。或者你可以阅读[官方教程](tutorial.html#tutorial)来深入了解你所需要的工具。你也可以查看附带样例的[接口参考](api.html#api-ref)来实现你不同的想法。
继续往下看,你有多个选择。比如你可能想去[安装 seaborn](installing.html#installing)。然后你可以看看[制图样例](http://seaborn.pydata.org/examples/index.html#example-gallery)来了解 seaborn 到底可以绘制什么样的图。或者你可以阅读[官方教程](tutorial.html#tutorial)来深入了解你所需要的工具。你也可以查看附带样例的[接口参考](api.html#api-ref)来实现你不同的想法。
......@@ -6,7 +6,7 @@
seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=None, col=None, col_wrap=None, row_order=None, col_order=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, markers=None, dashes=None, style_order=None, legend='brief', kind='scatter', height=5, aspect=1, facet_kws=None, **kwargs)
```
绘制相关关系图像到FacetGrid的图像级别接口。
绘制相关关系图像到 FacetGrid 的图像级别接口。
此函数提供对一些不同轴级别函数的访问,这些函数通过子集的语义映射显示两个变量之间的关系。`kind`参数选择要使用的基础轴级函数:
* [`scatterplot()`](seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot") (通过`kind="scatter"`访问;默认为此)
......@@ -16,11 +16,11 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
对于数据不同子集的`x``y`的绘制关系可以通过`hue`, `size`以及`style`参数控制。这些参数控制使用哪些视觉语义来区分不同的子集。使用所有三个语义类型可以独立展示三个维度,但是这种方式得到的绘制结果难以被理解而且低效。使用多种语义(例如对相同变量同时使用`hue``style`)可以使图像更加易懂。
参考[tutorial](../tutorial/relational.html#relational-tutorial)获得更多信息。
参考[tutorial](http://seaborn.pydata.org/tutorial/relational.html#relational-tutorial)获得更多信息。
绘制后,会返回带有图像的[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"),随后可以直接进行图像细节调节或者加入其他图层。
值得注意的是,与直接使用隐含函数的方式不同,数据必须以长格式的DataFrame传入,同时变量通过`x`, `y`及其他参数指定。
值得注意的是,与直接使用隐含函数的方式不同,数据必须以长格式的 DataFrame 传入,同时变量通过`x`, `y`及其他参数指定。
参数:`x, y``data`中的变量名
......@@ -40,7 +40,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
`data`:DataFrame
> 长格式的DataFrame,每列是一个变量,每行是一个观察值。
> 长格式的 DataFrame,每列是一个变量,每行是一个观察值。
`row, col``data`中的变量名,可选
......@@ -56,15 +56,15 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
`palette`:色盘名,列表,或者字典,可选
> 用于`hue`变量的不同级别的颜色。应当是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。应当是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者将色调级别映射到 matplotlib 颜色的字典。
`hue_order`:列表,可选
> 指定`hue`变量层级出现的顺序,否则会根据数据确定。当`hue`变量为数值型时与此无关。
`hue_norm`:元组或者Normalize对象,可选
`hue_norm`:元组或者 Normalize 对象,可选
> 当`hue`变量为数值型时,用于数据单元的colormap的标准化。如果`hue`为类别变量则与此无关。
> 当`hue`变量为数值型时,用于数据单元的 colormap 的标准化。如果`hue`为类别变量则与此无关。
`sizes`:列表、典或者元组,可选
......@@ -74,25 +74,25 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
> 指定`size`变量层次的表现顺序,不指定则会通过数据确定。当`size`变量为数值型时与此无关。
`size_norm`:元组或者Normalize对象,可选
`size_norm`:元组或者 Normalize 对象,可选
> 当`size`变量为数值型时,用于数据单元的scaling plot对象的标准化。
> 当`size`变量为数值型时,用于数据单元的 scaling plot 对象的标准化。
`legend`:“brief”, “full”, 或者False, 可选
`legend`:“brief”, “full”, 或者 False, 可选
> 用于决定如何绘制坐标轴。如果参数值为“brief”, 数值型的`hue`以及`size`变量将会被用等间隔采样值表示。如果参数值为“full”, 每组都会在坐标轴中被记录。如果参数值为“false”, 不会添加坐标轴数据,也不会绘制坐标轴。
`kind`:string, 可选
> 绘制图的类型,与seaborn相关的图一致。可选项为(`scatter`及`line`).
> 绘制图的类型,与 seaborn 相关的图一致。可选项为(`scatter`及`line`).
`height`:标量, 可选
> 每个facet的高度(英寸)。参见`aspect`。
> 每个 facet 的高度(英寸)。参见`aspect`。
`aspect`:标量, 可选
> 每个facet的长宽比,因此“长宽比*高度”可以得出每个facet的宽度(英寸)。
> 每个 facet 的长宽比,因此“长宽比*高度”可以得出每个 facet 的宽度(英寸)。
`facet_kws`:dict, 可选
......@@ -111,7 +111,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
示例
使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的坐标轴布局绘制简单的facet。
使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的坐标轴布局绘制简单的 facet。
```py
>>> import seaborn as sns
......@@ -123,7 +123,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
![http://seaborn.pydata.org/_images/seaborn-relplot-1.png](img/1c7fa44b0679b71a3e8e8a4e26d75963.jpg)
利用其他变量绘制facet:
利用其他变量绘制 facet:
```py
>>> g = sns.relplot(x="total_bill", y="tip",
......@@ -133,7 +133,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
![http://seaborn.pydata.org/_images/seaborn-relplot-2.png](img/f0eb2f840a13f8dbd2b829e6bb51c4af.jpg)
绘制两行两列的facet:
绘制两行两列的 facet:
```py
>>> g = sns.relplot(x="total_bill", y="tip", hue="day",
......@@ -143,7 +143,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
![http://seaborn.pydata.org/_images/seaborn-relplot-3.png](img/e6f2f0c866185be9801d43c59f348826.jpg)
将多行facets转换为多列:
将多行 facets 转换为多列:
```py
>>> g = sns.relplot(x="total_bill", y="tip", hue="time",
......@@ -153,7 +153,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
![http://seaborn.pydata.org/_images/seaborn-relplot-4.png](img/a89db144a2f030e70603b92ba8728326.jpg)
利用指定的属性值对每个facet使用多种语义变量:
利用指定的属性值对每个 facet 使用多种语义变量:
```py
>>> g = sns.relplot(x="total_bill", y="tip", hue="time", size="size",
......@@ -176,7 +176,7 @@ seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=
![http://seaborn.pydata.org/_images/seaborn-relplot-6.png](img/f14f4331afb42bd5512f2c24a5140604.jpg)
改变每个facet的大小:
改变每个 facet 的大小:
```py
>>> g = sns.relplot(x="timepoint", y="signal",
......
# seaborn.scatterplot
### seaborn.scatterplot
```py
> 译者:[leijuzi](https://github.com/leijuzi)
```python
seaborn.scatterplot(x=None, y=None, hue=None, style=None, size=None, data=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, markers=True, style_order=None, x_bins=None, y_bins=None, units=None, estimator=None, ci=95, n_boot=1000, alpha='auto', x_jitter=None, y_jitter=None, legend='brief', ax=None, **kwargs)
```
绘制几个语义分组的散点图。
Draw a scatter plot with possibility of several semantic groupings.
The relationship between `x` and `y` can be shown for different subsets of the data using the `hue`, `size`, and `style` parameters. These parameters control what visual semantics are used to identify the different subsets. It is possible to show up to three dimensions independently by using all three semantic types, but this style of plot can be hard to interpret and is often ineffective. Using redundant semantics (i.e. both `hue` and `style` for the same variable) can be helpful for making graphics more accessible.
See the [tutorial](../tutorial/relational.html#relational-tutorial) for more information.
参数:`x, y`:names of variables in `data` or vector data, optional
> Input data variables; must be numeric. Can pass data directly or reference columns in `data`.
数据的不同子集的 x 和 y 之间的关系可以用 hue, size, style 这三个参数来控制绘图属性。
这些参数控制用于识别不同子集的视觉语义信息,三种语义类型全部使用的话可以独立显示三个维度,
但是这种风格的绘图很难解释或者说没大部分时候什么效果。使用过多的语义信息
(例如:对同一个变量同时使用 hue 和 style)对作图来说是很有帮助同时也更容易理解。
`hue`:name of variables in `data` or vector data, optional
阅读下面的教程可以 get 更多信息哦。
> Grouping variable that will produce points with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
**参数**:
`x, y`: data 或是向量 data 里面的变量名字,可选择
> 输入数据的变量,必须是数字,可以直接传递数据或引用数据中的列
`size`:name of variables in `data` or vector data, optional
`hue`: data 或是向量 data 里面的变量名字,可选择
> 将产生不同大小的点的变量进行分组,可以是类别也可以是数字,
但是大小映射在后一种情况会有不同的表现
> Grouping variable that will produce points with different sizes. Can be either categorical or numeric, although size mapping will behave differently in latter case.
`style`:name of variables in `data` or vector data, optional
> Grouping variable that will produce points with different markers. Can have a numeric dtype but will always be treated as categorical.
`style`: data 或是向量 data 里面的变量名字,可选择
> 将产生不同标记的点的变量进行分类,可以有一个数字类型,但是这个数字会被当作类别
`data`:DataFrame
> Tidy (“long-form”) dataframe 它的每一列是一个变量,每一行是一个观测值
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
`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.
`hue_order`:list, optional
plaette : 调色板的名字、列表或字典,可选
> 用于不同 level 的 hue 变量的颜色,应该是可以被 color_palette() 执行的 something,
或者是一个可以对 matplotlib colors 映射 hue 级别的字典。
> Specified order for the appearance of the `hue` variable levels, otherwise they are determined from the data. Not relevant when the `hue` variable is numeric.
`hue_order`:列表,可选
> 对 hue 变量的级别的表象有特定的顺序,否则的话,顺序由 data 决定。当 hue 是数字的时候与它不相关
`hue_norm`:tuple or Normalize object, optional
`hue_norm`:元组或标准化的对象,可选
> 当 hue 变量是数字的时候,应用于 hue 变量的色彩映射的数据单元中的标准化。如果是类别则不相关
> Normalization in data units for colormap applied to the `hue` variable when it is numeric. Not relevant if it is categorical.
`sizes`:列表,字典或元组,可选
> 当使用 size 的时候,用来决定如何选择 sizes 的一个对象。可以一直是一个包含 size 数值的列表,
或者是一个映射变量 size 级别到 sizes 的字典。当 size 是数字时,sizes 可以是包含 size 最大值
和最小值的元组,其他的值都会标准化到这个元组指定的范围
`sizes`:list, dict, or tuple, optional
`size_order`:元组,可选
> size 变量级别表现的特定顺序,否则顺序由 data 决定,当 size 变量是数字时不相关
> An object that determines how sizes are chosen when `size` is used. It can always be a list of size values or a dict mapping levels of the `size` variable to sizes. When `size` is numeric, it can also be a tuple specifying the minimum and maximum size to use such that other values are normalized within this range.
`size_norm`:元组或标准化的对象,可选
> 当变量 size 是数字时,用于缩放绘图对象的数据单元中的标准化
`size_order`:list, optional
`makers`:布尔型,列表或字典,可选
> 决定如何绘制不同级别 style 的标志符号。设置为 True 会使用默认的标志符号,或者通过一系列标志
或者一个字典映射 style 变量的级别到 markers。设置为 False 会绘制无标志的线。
Markers 在 matplotlib 中指定
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
`style_order`:列表,可选
> 对于 style 变量级别表象的特定顺序,否则由 data 决定,当 style 是数字时不相关
`size_norm`:tuple or Normalize object, optional
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
`markers`:boolean, list, or dictionary, optional
> Object determining how to draw the markers for different levels of the `style` variable. Setting to `True` will use default markers, or you can pass a list of markers or a dictionary mapping levels of the `style` variable to markers. Setting to `False` will draw marker-less lines. Markers are specified as in matplotlib.
`style_order`:list, optional
> Specified order for appearance of the `style` variable levels otherwise they are determined from the data. Not relevant when the `style` variable is numeric.
`{x,y}_bins`:lists or arrays or functions
> _Currently non-functional._
`{x,y}_bins`: 元组,矩阵或函数
> 暂时没有什么功能
`units`:{long_form_var}
> 分组特定的样本单元。使用时,将为每个具有适当的语义的单元绘制一根单独的线,
但不会添加任何图例条目。 当不需要确切的身份时,可用于显示实验重复的分布。
目前没啥作用
> Grouping variable identifying sampling units. When used, a separate line will be drawn for each unit with appropriate semantics, but no legend entry will be added. Useful for showing distribution of experimental replicates when exact identities are not needed.
>
> _Currently non-functional._
`estimator`:name of pandas method or callable or None, optional
> Method for aggregating across multiple observations of the `y` variable at the same `x` level. If `None`, all observations will be drawn. _Currently non-functional._
`estimator`:pandas 方法的名称,或者可调用的方法或者是 None,可选
> 聚类同一个 x 上多个观察值 y,如果是 None,所有的观察值都会绘制,目前暂无功能
`ci`:int or “sd” or None, optional
`ci`:整型或 'sd' or None,可选
> 与估算器聚合时绘制的置信区间的大小。 “sd”表示绘制数据的标准偏差。 设置为 None 将跳过自举。 目前无功能。
> Size of the confidence interval to draw when aggregating with an estimator. “sd” means to draw the standard deviation of the data. Setting to `None` will skip bootstrapping. _Currently non-functional._
`n_boot`:整型,可选
> 自举法的数量,用于计算区间的置信度,暂无功能
`n_boot`:int, optional
`alpha`:浮点型
> 设置点的不透明度
> Number of bootstraps to use for computing the confidence interval. _Currently non-functional._
`{x,y}_jitter`:布尔或者浮点型
> 暂无功能
`alpha`:float
`legend`:“brief”, “full”, or False, 可选
> 绘制图例的方式。如果为“brief" 数字 hue 和 size 变量会代表一个样本,即便有不同的值
if "full", 每一个分组都有图例。if False 不绘制也不添加图例
> Proportional opacity of the points.
`ax`:matplotlib 坐标轴,可选
> 绘制图像的坐标对象,否则使用当前坐标轴
`{x,y}_jitter`:booleans or floats
`kwargs`:键值映射对
> 在绘制的时候其他的键会传递给 plt.scatter
> _Currently non-functional._
返回值:ax:matplotlib 坐标轴
> 返回绘制所需的坐标
`legend`:“brief”, “full”, or False, optional
请参阅官方文档
> How to draw the legend. If “brief”, numeric `hue` and `size` variables will be represented with a sample of evenly spaced values. If “full”, every group will get an entry in the legend. If `False`, no legend data is added and no legend is drawn.
用线显示两个变量之间的关系以强调连续性。绘制带有一个分类变量的散点图,排列点以显示值的分布。
`ax`:matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
`kwargs`:key, value mappings
> Other keyword arguments are passed down to `plt.scatter` at draw time.
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
See also
Show the relationship between two variables connected with lines to emphasize continuity.Draw a scatter plot with one categorical variable, arranging the points to show the distribution of values.
Examples
Draw a simple scatter plot between two variables:
```py
>>> import seaborn as sns; sns.set()
>>> import matplotlib.pyplot as plt
>>> tips = sns.load_dataset("tips")
>>> ax = sns.scatterplot(x="total_bill", y="tip", data=tips)
例子
绘制一个两个变量的简单散点图:
```python
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
tips = sns.load_dataset('tips')
ax = sns.scatterplot(x='total_bill',y='tip',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard1.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-1.png](img/0c0c7dd9c7bdb6a6490d4f09db142ec7.jpg)
Group by another variable and show the groups with different colors:
```py
>>> ax = sns.scatterplot(x="total_bill", y="tip", hue="time",
... data=tips)
通过其他的变量分组并且用不同的颜色展示分组
```python
ax = sns.scatterplot(x='total_bill',y='tip',hue='time',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard2.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-2.png](img/7fa2188b7e7f18a4af451121d39996f0.jpg)
Show the grouping variable by varying both color and marker:
```py
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="time", style="time", data=tips)
通过不同的颜色和标记显示分组变量:
```python
ax = sns.scatterplot(x='total_bill',y='tip',
hue='time',style='time',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard3.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-3.png](img/efc3bf2e49e981db42de96bfa2fbf3c3.jpg)
Vary colors and markers to show two different grouping variables:
```py
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="day", style="time", data=tips)
不同的颜色和标志显示两个不同的分组变量:
```python
ax = sns.scatterplot(x='total_bill',y='tip',
hue='day',style='time',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard4.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-4.png](img/9cd2a9e38e483ecbe02a7f0d0b67aac3.jpg)
Show a quantitative variable by varying the size of the points:
```py
>>> ax = sns.scatterplot(x="total_bill", y="tip", size="size",
... data=tips)
用不同大小的点显示一个变量的数量:
```python
ax = sns.scatterplot(x='total_bill',y='tip', size='size',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard5.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-5.png](img/eed42ab8c9334459069ea90987d5a184.jpg)
Also show the quantitative variable by also using continuous colors:
```py
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="size", size="size",
... data=tips)
使用渐变的颜色显示变量的数量:
```python
ax = sns.scatterplot(x='total_bill',y='tip',
hue='size', size='size',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard6.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-6.png](img/2777268c97b2e7b9d1e8269eb5a30c32.jpg)
Use a different continuous color map:
```py
>>> cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="size", size="size",
... palette=cmap,
... data=tips)
用一个不一样的渐变颜色映射:
```python
cmap = sns.cubehelix_palette(dark=.3,light=.8,as_cmap=True)
ax = sns.scatterplot(x='total_bill',y='tip',
hue='size', size='size',palette=cmap,data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard7.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-7.png](img/6254a35c0308633b36668290c5aecadd.jpg)
Change the minimum and maximum point size and show all sizes in legend:
```py
>>> cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="size", size="size",
... sizes=(20, 200), palette=cmap,
... legend="full", data=tips)
改变点大小的最小值和最大值并在图例中显示所有的尺寸:
```python
cmap = sns.cubehelix_palette(dark=.3,light=.8,as_cmap=True)
ax = sns.scatterplot(x='total_bill',y='tip',
hue='size',size='size', sizes=(20,200),legend='full',palette=cmap,data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard8.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-8.png](img/8dce33a113d5097dca0507c737d018d4.jpg)
Use a narrower range of color map intensities:
```py
>>> cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="size", size="size",
... sizes=(20, 200), hue_norm=(0, 7),
... legend="full", data=tips)
使用一个更小的颜色强度范围:
```python
cmap = sns.cubehelix_palette(dark=.3,light=.8,as_cmap=True)
ax = sns.scatterplot(x='total_bill',y='tip',hue='size',size='size',
sizes=(20,200),hue_norm=(0,7), legend='full',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard9.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-9.png](img/83eadbdb8a87de2c9615c02d627bb299.jpg)
Vary the size with a categorical variable, and use a different palette:
```py
>>> cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... hue="day", size="smoker",
... palette="Set2",
... data=tips)
一个类别变量不同的大小,用不同的颜色:
```python
ax = sns.scatterplot(x='total_bill',y='tip',hue='day',size='smoker',
palette='Set2',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard10.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-10.png](img/a5b1731f0fcd91611390c0bb109cfe64.jpg)
Use a specific set of markers:
```py
>>> markers = {"Lunch": "s", "Dinner": "X"}
>>> ax = sns.scatterplot(x="total_bill", y="tip", style="time",
... markers=markers,
... data=tips)
使用一些特定的标识:
```python
markers = {'Lunch':'s','Dinner':'X'}
ax = sns.scatterplot(x='total_bill',y='tip',style='time',
markers=markers,data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard11.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-11.png](img/d36b6251be5569fe2c31daea7543bf8a.jpg)
Control plot attributes using matplotlib parameters:
```py
>>> ax = sns.scatterplot(x="total_bill", y="tip",
... s=100, color=".2", marker="+",
... data=tips)
使用 matplotlib 的参数控制绘制属性:
```python
ax = sns.scatterplot(x='total_bill',y='tip',
s=100,color='.2',marker='+',data=tips)
```
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard12.png)
![http://seaborn.pydata.org/_images/seaborn-scatterplot-12.png](img/6096554e5a6fc5659cb1506870489993.jpg)
Pass data vectors instead of names in a data frame:
```py
>>> iris = sns.load_dataset("iris")
>>> ax = sns.scatterplot(x=iris.sepal_length, y=iris.sepal_width,
... hue=iris.species, style=iris.species)
使用 data 向量代替 data frame 名字:
```python
iris = sns.load_dataset('iris')
ax = sns.scatterplot(x=iris.sepal_length,y=iris.sepal_width,
hue = iris.species,style=iris.species)
```
![http://seaborn.pydata.org/_images/seaborn-scatterplot-13.png](img/5efb6c24bde137217b7d6471bd9e806a.jpg)
Pass a wide-form dataset and plot against its index:
```py
>>> import numpy as np, pandas as pd; plt.close("all")
>>> index = pd.date_range("1 1 2000", periods=100,
... freq="m", name="date")
>>> data = np.random.randn(100, 4).cumsum(axis=0)
>>> wide_df = pd.DataFrame(data, index, ["a", "b", "c", "d"])
>>> ax = sns.scatterplot(data=wide_df)
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard13.png)
传递宽格式数据并根据其索引进行绘图:
```python
import numpy as np, pandas as pd; plt.close("all")
index = pd.date_range('1 1 2000',periods=100,freq='m',name='date')
data = np.random.randn(100,4).cumsum(axis=0)
wide_df = pd.DataFrame(data,index,['a','b','c','d'])
print(wide_df.head())
ax = sns.scatterplot(data=wide_df)
```
![http://seaborn.pydata.org/_images/seaborn-scatterplot-14.png](img/ef47abe0a6cdede1f181c16d59bd3fe0.jpg)
\ No newline at end of file
![](https://raw.githubusercontent.com/leijuzi/img_seaborn_11/master/img_11/clipboard14.png)
\ No newline at end of file
# seaborn.lineplot
# **seaborn.lineplot**
```py
> 译者:[cancan233](https://github.com/cancan233)
```python
seaborn.lineplot(x=None, y=None, hue=None, size=None, style=None, data=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, dashes=True, markers=None, style_order=None, units=None, estimator='mean', ci=95, n_boot=1000, sort=True, err_style='band', err_kws=None, legend='brief', ax=None, **kwargs)
```
Draw a line plot with possibility of several semantic groupings.
The relationship between `x` and `y` can be shown for different subsets of the data using the `hue`, `size`, and `style` parameters. These parameters control what visual semantics are used to identify the different subsets. It is possible to show up to three dimensions independently by using all three semantic types, but this style of plot can be hard to interpret and is often ineffective. Using redundant semantics (i.e. both `hue` and `style` for the same variable) can be helpful for making graphics more accessible.
See the [tutorial](../tutorial/relational.html#relational-tutorial) for more information.
By default, the plot aggregates over multiple `y` values at each value of `x` and shows an estimate of the central tendency and a confidence interval for that estimate.
参数:`x, y`:names of variables in `data` or vector data, optional
> Input data variables; must be numeric. Can pass data directly or reference columns in `data`.
用不同语义分组绘制线型图
`hue`:name of variables in `data` or vector data, optional
`x``y`之间的关系可以使用`hue``size``style`参数为数据的不同子集显示。这些参数控制用于识别不同子集的视觉语义。通过使用所有三种语义类型,可以独立地显示三个维度,但是这种画图样式可能难以解释并且通常是无效的。使用冗余语义(即同一变量的`hue``style`)有助于使图形更易于理解。
> Grouping variable that will produce lines with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
请查看[指南](http://seaborn.pydata.org/tutorial/relational.html#relational-tutoria)获取更多信息。
`size`:name of variables in `data` or vector data, optional
默认情况下,图标在每个`x`值处汇总多个`y`值,并显示集中趋势的估计值和该估计值的置信区间。
> Grouping variable that will produce lines with different widths. Can be either categorical or numeric, although size mapping will behave differently in latter case.
参数:`x,y``data`或向量数据中变量的名称,可选择。
`style`:name of variables in `data` or vector data, optional
> 输入数据变量;必须是数字。可以直接传递数据或引用`data`中的列。
> Grouping variable that will produce lines with different dashes and/or markers. Can have a numeric dtype but will always be treated as categorical.
`hue`: `data`或向量数据中的变量名,可选。
`data`:DataFrame
> 分组变量,将生成具有不同颜色的线条的变量。可以是分类或数字,但颜色映射在后一种情况下的行为会有所不同。
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
`size`: `data`或向量数据中的变量名,可选。
`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.
`style`: `data`或向量数据中的变量名,可选。
`hue_order`:list, optional
> 分组变量,将生成具有不同样式和/或标记的线条的变量。可以是一种数字形式,但是始终会被视为分类。
> Specified order for the appearance of the `hue` variable levels, otherwise they are determined from the data. Not relevant when the `hue` variable is numeric.
`data`: 数据框架。
`hue_norm`:tuple or Normalize object, optional
> 整洁(“长形式”)数据框,其中每列是变量,每行是观察量。
> Normalization in data units for colormap applied to the `hue` variable when it is numeric. Not relevant if it is categorical.
`palette`: 调色板名称,列表或字典,可选。
`sizes`:list, dict, or tuple, optional
> 用于`hue`变量的不同级别的颜色。应该是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者是将色调级别映射到 matplotlib 颜色的字典。
> An object that determines how sizes are chosen when `size` is used. It can always be a list of size values or a dict mapping levels of the `size` variable to sizes. When `size` is numeric, it can also be a tuple specifying the minimum and maximum size to use such that other values are normalized within this range.
`hue_order`:列表,可选。
`size_order`:list, optional
> 指定`hue`变量级别的出现顺序,否则它们是根据数据确定的。当`hue`变量是数字时不相关。
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
`hue_norm`: 原则或者时归一化对象,可选。
`size_norm`:tuple or Normalize object, optional
> 当数值为数字时,应用于`hue`变量的颜色图数据单元的归一化。 如果是分类的,则不相关。
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
`sizes`:列表,字典,或者元组。可选。
`dashes`:boolean, list, or dictionary, optional
> 确定在使用`size`时如何选择大小的对象。它始终可以是大小值列表或`size`变量与大小的字典映射级别。当`size`是数字时,它也可以是一个元组,指定要使用的最小和最大大小,以便在此范围内对其他值进行规范化。
> Object determining how to draw the lines for different levels of the `style` variable. Setting to `True` will use default dash codes, or you can pass a list of dash codes or a dictionary mapping levels of the `style` variable to dash codes. Setting to `False` will use solid lines for all subsets. Dashes are specified as in matplotlib: a tuple of `(segment, gap)` lengths, or an empty string to draw a solid line.
`size_norm`:原则或者时归一化对象,可选。
`markers`:boolean, list, or dictionary, optional
> 当`size`变量是数字时,用于缩放绘图对象的数据单元中的归一化。
> Object determining how to draw the markers for different levels of the `style` variable. Setting to `True` will use default markers, or you can pass a list of markers or a dictionary mapping levels of the `style` variable to markers. Setting to `False` will draw marker-less lines. Markers are specified as in matplotlib.
`dashes`: 布尔值,列表或字典,可选。
`style_order`:list, optional
> 确定如何为`style`变量的不同级别绘制线条的对象。设置为`True`将使用默认的短划线代码,或者您可以将短划线代码列表或`style`变量的字典映射级别传递给短划线代码。设置为`False`将对所有子集使用实线。线段在 matplotlib 中指定: `(segment, gap)`长度的元组,或用于绘制实线的空字符串。
> Specified order for appearance of the `style` variable levels otherwise they are determined from the data. Not relevant when the `style` variable is numeric.
`markers`: 布尔值,列表或字典,可选。
`units`:{long_form_var}
> 确定如何为`style`变量的不同级别绘制标记的对象。 设置为“True”将使用默认标记,或者您可以传递标记列表或将`style`变量的字典映射到标记。 设置为“False”将绘制无标记线。 标记在 matplotlib 中指定。
> Grouping variable identifying sampling units. When used, a separate line will be drawn for each unit with appropriate semantics, but no legend entry will be added. Useful for showing distribution of experimental replicates when exact identities are not needed.
`style_order`:列表,可选。
`estimator`:name of pandas method or callable or None, optional
> 指定`style`变量级别的出现顺序,否则它们是从数据中确定的。`style`变量时数字不相关的。
> Method for aggregating across multiple observations of the `y` variable at the same `x` level. If `None`, all observations will be drawn.
`units`: {long_form_var}
`ci`:int or “sd” or None, optional
> 对变量识别抽样单位进行分组。使用时,将为每个单元绘制一个单独的行,并使用适当的语义。但不会添加任何图里条目。当不需要确切的身份时,可用于显示实验重复的分布。
> Size of the confidence interval to draw when aggregating with an estimator. “sd” means to draw the standard deviation of the data. Setting to `None` will skip bootstrapping.
`estimator`:pandas 方法的名称或可调用或无,可选。
`n_boot`:int, optional
> 在相同的`x`级别上聚合`y`变量的多个观察值的方法。如果`None`,将绘制所有观察结果。
> Number of bootstraps to use for computing the confidence interval.
`ci`:整数或`sd`或 None。可选。
`sort`:boolean, optional
> 与`estimator`聚合时绘制的置信区间大小。`sd`表示绘制数据的标准偏差。设置为`None`将跳过 bootstrap。
> If True, the data will be sorted by the x and y variables, otherwise lines will connect points in the order they appear in the dataset.
`n_boot`:整数,可选。
`err_style`:“band” or “bars”, optional
> 用于计算置信区间的 bootstrap 数。
> Whether to draw the confidence intervals with translucent error bands or discrete error bars.
`sort`:布尔值,可选。
`err_band`:dict of keyword arguments
> 如果为真,则数据将按 x 与 y 变量排序,否则行将按照它们在数据集中出现的顺序连接点。
> Additional paramters to control the aesthetics of the error bars. The kwargs are passed either to `ax.fill_between` or `ax.errorbar`, depending on the `err_style`.
`err_style`: `band``bars`,可选。
`legend`:“brief”, “full”, or False, optional
> 是否用半透明误差带或离散误差棒绘制置信区间。
> How to draw the legend. If “brief”, numeric `hue` and `size` variables will be represented with a sample of evenly spaced values. If “full”, every group will get an entry in the legend. If `False`, no legend data is added and no legend is drawn.
`err_band`:关键字参数字典。
`ax`:matplotlib Axes, optional
> 用于控制误差线美观的附加参数。 `kwargs`传递给`ax.fill_between`或`ax.errorbar`,具体取决于`err_style`。
> Axes object to draw the plot onto, otherwise uses the current Axes.
`legend``brief`,`full`,或`False`。可选。
`kwargs`:key, value mappings
> 如何绘制图例。如果`brief`,则数字`hue`和`size`变量将用均匀间隔值的样本表示。如果`full`,则每个组都会在图例中输入一个条目。如果为`False`,则不添加图例数据且不绘制图例。
> Other keyword arguments are passed down to `plt.plot` at draw time.
`ax`:matplotlib 轴。可选。
> 将绘图绘制到的 Axes 对象,否则使用当前轴。
返回值:`ax`:matplotlib Axes
`kwargs`:关键,价值映射。
> Returns the Axes object with the plot drawn onto it.
> 其他关键字参数在绘制时传递给`plt.plot`。
返回值:`ax`:matplotlib 轴
> 返回 Axes 对象,并在其上绘制绘图。
See also
也可以看看
Show the relationship between two variables without emphasizing continuity of the `x` variable.Show the relationship between two variables when one is categorical.
显示两个变量之间的关系,而不强调`x`变量的连续性。当两个变量时分类时,显示两个变量之间的关系。
Examples
例子
Draw a single line plot with error bands showing a confidence interval:
绘制单线图,其中错误带显示执行区间:
```py
>>> import seaborn as sns; sns.set()
......@@ -133,7 +128,7 @@ Draw a single line plot with error bands showing a confidence interval:
![http://seaborn.pydata.org/_images/seaborn-lineplot-1.png](img/25ad91543cb2ac105ccfb3efc544658a.jpg)
Group by another variable and show the groups with different colors:
按另一个变量分组并显示具有不同颜色的组:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal", hue="event",
......@@ -143,7 +138,7 @@ Group by another variable and show the groups with different colors:
![http://seaborn.pydata.org/_images/seaborn-lineplot-2.png](img/5d2d2c464b8872f780180217182517d4.jpg)
Show the grouping variable with both color and line dashing:
使用颜色和线条划线显示分组变量:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal",
......@@ -153,7 +148,7 @@ Show the grouping variable with both color and line dashing:
![http://seaborn.pydata.org/_images/seaborn-lineplot-3.png](img/2e99f3ab69ddcc3a94df1ddb15068249.jpg)
Use color and line dashing to represent two different grouping variables:
使用颜色和线条划线来表示两个不同的分组变量:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal",
......@@ -163,7 +158,7 @@ Use color and line dashing to represent two different grouping variables:
![http://seaborn.pydata.org/_images/seaborn-lineplot-4.png](img/7c717f27fe7c1e02672338abf7cad829.jpg)
Use markers instead of the dashes to identify groups:
使用标记而不是破折号来标识组:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal",
......@@ -174,7 +169,7 @@ Use markers instead of the dashes to identify groups:
![http://seaborn.pydata.org/_images/seaborn-lineplot-5.png](img/f82003c5544990262fe9a61a131d93ef.jpg)
Show error bars instead of error bands and plot the standard error:
显示错误条而不是错误带并绘制标准错误:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal", hue="event",
......@@ -184,7 +179,7 @@ Show error bars instead of error bands and plot the standard error:
![http://seaborn.pydata.org/_images/seaborn-lineplot-6.png](img/a92991eef59fbedc422f330f51697fe4.jpg)
Show experimental replicates instead of aggregating:
显示实验性重复而不是聚合:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal", hue="event",
......@@ -195,7 +190,7 @@ Show experimental replicates instead of aggregating:
![http://seaborn.pydata.org/_images/seaborn-lineplot-7.png](img/d7a78945c0ae60bbd5ee9dfef15baba0.jpg)
Use a quantitative color mapping:
使用定量颜色映射:
```py
>>> dots = sns.load_dataset("dots").query("align == 'dots'")
......@@ -207,7 +202,7 @@ Use a quantitative color mapping:
![http://seaborn.pydata.org/_images/seaborn-lineplot-8.png](img/bc93752a335d8985139584678e19a2b9.jpg)
Use a different normalization for the colormap:
对 colormap 使用不同的归一化:
```py
>>> from matplotlib.colors import LogNorm
......@@ -219,7 +214,7 @@ Use a different normalization for the colormap:
![http://seaborn.pydata.org/_images/seaborn-lineplot-9.png](img/1848472fd25a5227de0c58b2fc43c865.jpg)
Use a different color palette:
使用不同的调色板:
```py
>>> ax = sns.lineplot(x="time", y="firing_rate",
......@@ -230,7 +225,7 @@ Use a different color palette:
![http://seaborn.pydata.org/_images/seaborn-lineplot-10.png](img/f758b47e18df4e0b8e31c3a3fb9a1634.jpg)
Use specific color values, treating the hue variable as categorical:
使用特定颜色值,将 hue 变量视为分类:
```py
>>> palette = sns.color_palette("mako_r", 6)
......@@ -242,7 +237,7 @@ Use specific color values, treating the hue variable as categorical:
![http://seaborn.pydata.org/_images/seaborn-lineplot-11.png](img/f91976efc3d73db2b134c57ba7dd86f3.jpg)
Change the width of the lines with a quantitative variable:
使用定量变量更改线条的宽度:
```py
>>> ax = sns.lineplot(x="time", y="firing_rate",
......@@ -253,7 +248,7 @@ Change the width of the lines with a quantitative variable:
![http://seaborn.pydata.org/_images/seaborn-lineplot-12.png](img/f7c110a02ff0dffcc8a6c88582b45b70.jpg)
Change the range of line widths used to normalize the size variable:
更改用于规范化 size 变量的线宽范围:
```py
>>> ax = sns.lineplot(x="time", y="firing_rate",
......@@ -264,7 +259,7 @@ Change the range of line widths used to normalize the size variable:
![http://seaborn.pydata.org/_images/seaborn-lineplot-13.png](img/438199f3698b863dd842a2f680c4a845.jpg)
Plot from a wide-form DataFrame:
DataFrame 绘制:
```py
>>> import numpy as np, pandas as pd; plt.close("all")
......@@ -278,7 +273,7 @@ Plot from a wide-form DataFrame:
![http://seaborn.pydata.org/_images/seaborn-lineplot-14.png](img/25659857727e22d0f951f9c750bb29de.jpg)
Plot from a list of Series:
系列列表中绘制:
```py
>>> list_data = [wide_df.loc[:"2005", "a"], wide_df.loc["2003":, "b"]]
......@@ -288,7 +283,7 @@ Plot from a list of Series:
![http://seaborn.pydata.org/_images/seaborn-lineplot-15.png](img/711ff3dd5a0aef63679fe4174259ee3d.jpg)
Plot a single Series, pass kwargs to `plt.plot`:
绘制单个系列,将 kwargs 传递给`plt.plot`
```py
>>> ax = sns.lineplot(data=wide_df["a"], color="coral", label="line")
......@@ -297,7 +292,7 @@ Plot a single Series, pass kwargs to `plt.plot`:
![http://seaborn.pydata.org/_images/seaborn-lineplot-16.png](img/fde16964145ae355ddbbeae37728260a.jpg)
Draw lines at points as they appear in the dataset:
在数据集中出现的点处绘制线条:
```py
>>> x, y = np.random.randn(2, 5000).cumsum(axis=1)
......@@ -305,4 +300,4 @@ Draw lines at points as they appear in the dataset:
```
![http://seaborn.pydata.org/_images/seaborn-lineplot-17.png](img/05782b02c2faaf09a504b53a5a526445.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-lineplot-17.png](img/05782b02c2faaf09a504b53a5a526445.jpg)
......@@ -6,7 +6,7 @@
seaborn.catplot(x=None, y=None, hue=None, data=None, row=None, col=None, col_wrap=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, order=None, hue_order=None, row_order=None, col_order=None, kind='strip', height=5, aspect=1, orient=None, color=None, palette=None, legend=True, legend_out=True, sharex=True, sharey=True, margin_titles=False, facet_kws=None, **kwargs)
```
seaborn.catplot 是一个将分类图绘制到FacetGrid上图级别接口。
seaborn.catplot 是一个将分类图绘制到 FacetGrid 上图级别接口。
这个函数可以访问多个轴级功能,这些轴级功能通过不同的可视化图表展示数字和一个或多个分类变量的关系。`kind` 参数可以选择的轴级基础函数有:
......@@ -29,13 +29,13 @@ seaborn.catplot 是一个将分类图绘制到FacetGrid上图级别接口。
额外的关键字参数将传递给基础函数,因此,您应参阅每个文档,以查看特定类型的选项.
请注意,与直接使用轴级函数不同, 数据必须在长格式DataFrame中传递,并通过将字符串传递给 `x`, `y`, `hue`, 等指定的变量.
请注意,与直接使用轴级函数不同, 数据必须在长格式 DataFrame 中传递,并通过将字符串传递给 `x`, `y`, `hue`, 等指定的变量.
与基础绘图函数的情况一样, 如果变量有 `categorical` 数据类型, 则将从对象推断出分类变量的级别及其顺序。否则,您可能必须使用更改 dataframe 排序或使用函数参数(`orient`, `order`, `hue_order`, etc.) 来正确设置绘图。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型。
有关更多信息,请参考 [tutorial](../tutorial/categorical.html#categorical-tutorial)
有关更多信息,请参考 [tutorial](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
绘图后,返回带有绘图的 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"),可以直接用于调整绘图细节或添加其他图层。
......@@ -59,7 +59,7 @@ seaborn.catplot 是一个将分类图绘制到FacetGrid上图级别接口。
> 在每个分类箱内估计的统计函数。
`ci`:float或“sd”或None,可选
`ci`:float 或“sd”或 None,可选
> 在估计值附近绘制置信区间的大小。如果是“sd”,则跳过自举(bootstrapping)并绘制观察的标准偏差。None,如果为`None`,则不执行自举,并且不会绘制错误条。
......@@ -93,15 +93,15 @@ seaborn.catplot 是一个将分类图绘制到FacetGrid上图级别接口。
`orient`:“v” &#124; “h”, 可选
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> 图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
`color`:matplotlib颜色,可选
`color`:matplotlib 颜色,可选
> 所有元素的颜色,或渐变调色板的种子。
`palette`:调色板名称,列表或字典,可选
> 用于色调变量的不同级别的颜色。应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> 用于色调变量的不同级别的颜色。应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 可以解释的东西,或者是将色调级别映射到 matplotlib 颜色的字典。
`legend`:bool, 可选
......@@ -114,7 +114,7 @@ seaborn.catplot 是一个将分类图绘制到FacetGrid上图级别接口。
`share{x,y}`:bool, ‘col’, 或 ‘row’ 可选
> 如果为true,则facet将跨行跨越列和/或x轴共享y轴。
> 如果为 true,则 facet 将跨行跨越列和/或 x 轴共享 y 轴。
`margin_titles`:bool, 可选
......
......@@ -12,16 +12,16 @@ seaborn.stripplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
输入数据可以以多种格式传递,包括:
* 表示为列表,numpy数组或pandas Series对象的数据向量直接传递给`x``y``hue`参数
* 表示为列表,numpy 数组或 pandas Series 对象的数据向量直接传递给`x``y``hue`参数
* 在这种情况下,`x``y``hue`变量将决定数据的绘制方式。
* “wide-form” DataFrame, 用于绘制每个数字列。
* 一个数组或向量列表。
在大多数情况下,可以使用numpy或Python对象,但最好使用pandas对象,因为关联的名称将用于注释轴。另外,您可以使用分组变量的分类类型来控制绘图元素的顺序。
在大多数情况下,可以使用 numpy 或 Python 对象,但最好使用 pandas 对象,因为关联的名称将用于注释轴。另外,您可以使用分组变量的分类类型来控制绘图元素的顺序。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型也是如此。
有关更多信息,请参阅[教程](../tutorial/categorical.html#categorical-tutorial)
有关更多信息,请参阅[教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``数据`或矢量数据中的变量名称,可选
......@@ -45,21 +45,21 @@ seaborn.stripplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`orient`:“v” &#124; “h”, 可选
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> 图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
`color`:matplotlib颜色,可选
`color`:matplotlib 颜色,可选
> 所有元素的颜色,或渐变调色板的种子。
`palette`:调色板名称,列表或字典,可选
> 用于色调变量的不同级别的颜色。应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> 用于色调变量的不同级别的颜色。应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 可以解释的东西,或者是将色调级别映射到 matplotlib 颜色的字典。
`size`:float, 可选
> 标记的直径,以磅为单位。(虽然 `plt.scatter` 用于绘制点,但这里的 `size` 参数采用“普通”标记大小而不是大小^ 2,如 `plt.scatter` 。
`edgecolor`:matplotlib颜色,“灰色”是特殊的,可选的
`edgecolor`:matplotlib 颜色,“灰色”是特殊的,可选的
>每个点周围线条的颜色。如果传递`"灰色"`,则亮度由用于点体的调色板决定。
......@@ -67,20 +67,20 @@ seaborn.stripplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
> 构图元素的灰线宽度。
`ax`:matplotlib轴,可选
`ax`:matplotlib 轴,可选
> 返回Axes对象,并在其上绘制绘图。
> 返回 Axes 对象,并在其上绘制绘图。
返回值:`ax`:matplotlib轴
返回值:`ax`:matplotlib
> 返回Axes对象,并在其上绘制绘图。
> 返回 Axes 对象,并在其上绘制绘图。
也可参看
分类散点图,其中点不重叠。可以与其他图一起使用来显示每个观察结果。带有类似API的传统盒须图。箱形图和核密度估计的组合。
分类散点图,其中点不重叠。可以与其他图一起使用来显示每个观察结果。带有类似 API 的传统盒须图。箱形图和核密度估计的组合。
例子
......
# seaborn.swarmplot
> 译者:[LIJIANcoder97](https://github.com/LIJIANcoder97)
```py
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)
```
......@@ -13,16 +15,16 @@ seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
正确排列点需要在数据和点坐标之间进行精确转换。这意味着必须在绘制绘图之前设置非默认轴限制。
输入数据可以以多种格式传递,包括:
* 表示为列表,numpy arrays或pandas Series objects直接传递给`x``y`和/或`hue`参数。
* 表示为列表,numpy arrays 或 pandas Series objects 直接传递给`x``y`和/或`hue`参数。
* “长格式” DataFrame, `x``y``hue`变量将决定数据的绘制方式
* “宽格式”DataFrame,用于绘制每个数字列。
* 一个数组或向量列表。
在大多数情况下,可以使用numpy或Python对象,但最好使用pandas对象,因为关联的名称将用于注释轴。此外,您可以使用分类类型来分组变量来控制绘图元素的顺序。
在大多数情况下,可以使用 numpy 或 Python 对象,但最好使用 pandas 对象,因为关联的名称将用于注释轴。此外,您可以使用分类类型来分组变量来控制绘图元素的顺序。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型也是如此
有关更多信息,请参阅[教程](../tutorial/categorical.html#categorical-tutorial)
有关更多信息,请参阅[教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``数据`或矢量数据中的变量名称,可选
......@@ -42,7 +44,7 @@ seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`orient`:“v” &#124; “h”, 可选
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> 图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
`color`:matplotlib color, 可选
......@@ -50,7 +52,7 @@ seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`palette`:调色板名称, list, or dict, 可选
> 用于`hue`变量的不同级别的颜色。应该是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"),可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。应该是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"),可以解释的东西,或者是将色调级别映射到 matplotlib 颜色的字典。
`size`:float, 可选
......@@ -66,18 +68,18 @@ seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`ax`:matplotlib Axes, 可选
> Axes对象将绘图绘制到,否则使用当前轴。
> Axes 对象将绘图绘制到,否则使用当前轴。
返回值:`ax`:matplotlib Axes
> 返回Axes对象,并在其上绘制绘图。
> 返回 Axes 对象,并在其上绘制绘图。
参看
带有类似API的传统盒须图。框图和核密度估计的组合。散点图,其中一个变量是分类的。可以与其他图一起使用以显示每个观察结果。使用类组合分类图:<cite>FacetGrid</cite>
带有类似 API 的传统盒须图。框图和核密度估计的组合。散点图,其中一个变量是分类的。可以与其他图一起使用以显示每个观察结果。使用类组合分类图:<cite>FacetGrid</cite>
......@@ -130,7 +132,7 @@ seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
![http://seaborn.pydata.org/_images/seaborn-swarmplot-5.png](img/6f9585fcbe42e72521292b80b0fdc97a.jpg)
通过传递显式顺序来控制swarm顺序:
通过传递显式顺序来控制 swarm 顺序:
```py
>>> ax = sns.swarmplot(x="time", y="tip", data=tips,
......
......@@ -12,16 +12,16 @@ seaborn.boxplot 接口的作用是绘制箱形图以展现与类别相关的数
输入数据可以通过多种格式传入,包括:
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 格式为列表,numpy 数组或 pandas Series 对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的 DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的 DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
在大多数情况下,可以使用 numpy 或 Python 对象,但更推荐使用 pandas 对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
更多信息请参阅 [教程](../tutorial/categorical.html#categorical-tutorial)
更多信息请参阅 [教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``数据`或向量数据中的变量名称,可选
......@@ -37,15 +37,15 @@ seaborn.boxplot 接口的作用是绘制箱形图以展现与类别相关的数
`orient`:“v” &#124; “h”,可选
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
`color`:matplotlib颜色,可选
`color`:matplotlib 颜色,可选
> 所有元素的颜色,或渐变调色板的种子颜色。
`palette`:调色板名称,列表或字典,可选
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到 matplotlib 颜色的字典。
`saturation`:float,可选
......@@ -69,30 +69,30 @@ seaborn.boxplot 接口的作用是绘制箱形图以展现与类别相关的数
`whis`:float,可选
> 控制在超过高低四分位数时IQR的比例,因此需要延长绘制的触须线段。超出此范围的点将被识别为异常值。
> 控制在超过高低四分位数时 IQR 的比例,因此需要延长绘制的触须线段。超出此范围的点将被识别为异常值。
`notch`:boolean,可选
> 是否使矩形框“凹陷”以指示中位数的置信区间。还有其他几个参数可以控制凹槽的绘制方式;参见 `plt.boxplot` 以查看关于此问题的更多帮助信息。
`ax`:matplotlib轴,可选
`ax`:matplotlib 轴,可选
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
> 绘图时使用的 Axes 轴对象,否则使用当前 Axes 轴对象。
`kwargs`:键,值映射
> 其他在绘图时传给 `plt.boxplot` 的参数。
返回值:`ax`:matplotlib轴
返回值:`ax`:matplotlib
> 返回Axes对轴象,并在其上绘制绘图。
> 返回 Axes 对轴象,并在其上绘制绘图。
亦可参见
boxplot和核密度估计的结合。当一个变量是分类变量的散点图。可以与其他图表结合使用以展示各自的观测结果。分类散点图的特点是其中数据点互不重叠。可以与其他图表结合使用以展示各自的观测结果。
boxplot 和核密度估计的结合。当一个变量是分类变量的散点图。可以与其他图表结合使用以展示各自的观测结果。分类散点图的特点是其中数据点互不重叠。可以与其他图表结合使用以展示各自的观测结果。
示例
......@@ -117,7 +117,7 @@ boxplot和核密度估计的结合。当一个变量是分类变量的散点图
![http://seaborn.pydata.org/_images/seaborn-boxplot-2.png](img/26d08ab02c44cb0a819065f27a1b7f84.jpg)
根据2个分类变量嵌套分组绘制一个箱型图:
根据 2 个分类变量嵌套分组绘制一个箱型图:
```py
>>> ax = sns.boxplot(x="day", y="total_bill", hue="smoker",
......@@ -147,7 +147,7 @@ boxplot和核密度估计的结合。当一个变量是分类变量的散点图
![http://seaborn.pydata.org/_images/seaborn-boxplot-5.png](img/8ac363c4f6fd1e8ef5a4dd62d236ce9d.jpg)
针对DataFrame里每一个数值型变量绘制箱型图:
针对 DataFrame 里每一个数值型变量绘制箱型图:
```py
>>> iris = sns.load_dataset("iris")
......
......@@ -14,16 +14,16 @@ seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=No
输入数据可以通过多种格式传入,包括:
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 格式为列表,numpy 数组或 pandas Series 对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的 DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的 DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
在大多数情况下,可以使用 numpy 或 Python 对象,但更推荐使用 pandas 对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
更多信息请参阅 [tutorial](../tutorial/categorical.html#categorical-tutorial)
更多信息请参阅 [tutorial](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``数据`或向量数据中的变量名称,可选
......@@ -43,7 +43,7 @@ seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=No
`cut`:float,可选
> 以带宽大小为单位的距离,以控制小提琴图外壳延伸超过内部极端数据点的密度。设置为0以将小提琴图范围限制在观察数据的范围内。(例如,在 `ggplot` 中具有与 `trim=True` 相同的效果)
> 以带宽大小为单位的距离,以控制小提琴图外壳延伸超过内部极端数据点的密度。设置为 0 以将小提琴图范围限制在观察数据的范围内。(例如,在 `ggplot` 中具有与 `trim=True` 相同的效果)
`scale`:{“area”, “count”, “width”},可选
......@@ -67,7 +67,7 @@ seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=No
`split`:bool,可选
> 当使用带有两种颜色的变量时,将`split`设置为True则会为每种颜色绘制对应半边小提琴。从而可以更容易直接的比较分布。
> 当使用带有两种颜色的变量时,将`split`设置为 True 则会为每种颜色绘制对应半边小提琴。从而可以更容易直接的比较分布。
`dodge`:bool,可选
......@@ -75,38 +75,38 @@ seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=No
`orient`:“v” &#124; “h”,可选
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
`linewidth`:float,可选
> 构图元素的灰线宽度。
`color`:matplotlib颜色,可选
`color`:matplotlib 颜色,可选
> 所有元素的颜色,或渐变调色板的种子颜色。
`palette`:调色板名称,列表或字典,可选
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到 matplotlib 颜色的字典。
`saturation`:float,可选
> 控制用于绘制颜色的原始饱和度的比例。通常大幅填充在轻微不饱和的颜色下看起来更好,如果您希望绘图颜色与输入颜色规格完美匹配可将其设置为`1`。
`ax`:matplotlib轴,可选
`ax`:matplotlib 轴,可选
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
> 绘图时使用的 Axes 轴对象,否则使用当前 Axes 轴对象。
返回值:`ax`:matplotlib轴
返回值:`ax`:matplotlib
> 返回Axes对轴象,并在其上绘制绘图。
> 返回 Axes 对轴象,并在其上绘制绘图。
亦可参见
一个传统的箱型图具有类似的API。当一个变量是分类变量的散点图。可以与其他图表结合使用以展示各自的观测结果。分类散点图的特点是其中数据点互不重叠。可以与其他图表结合使用以展示各自的观测结果。
一个传统的箱型图具有类似的 API。当一个变量是分类变量的散点图。可以与其他图表结合使用以展示各自的观测结果。分类散点图的特点是其中数据点互不重叠。可以与其他图表结合使用以展示各自的观测结果。
示例
......@@ -131,7 +131,7 @@ seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=No
![http://seaborn.pydata.org/_images/seaborn-violinplot-2.png](img/35c303fe21899eb631a454ab2d09e1bf.jpg)
根据2个分类变量嵌套分组绘制一个小提琴图:
根据 2 个分类变量嵌套分组绘制一个小提琴图:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="smoker",
......
......@@ -14,16 +14,16 @@ seaborn.boxenplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
输入数据可以通过多种格式传入,包括:
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 格式为列表,numpy 数组或 pandas Series 对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的 DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的 DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
在大多数情况下,可以使用 numpy 或 Python 对象,但更推荐使用 pandas 对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
更多信息请参阅 [教程](../tutorial/categorical.html#categorical-tutorial)
更多信息请参阅 [教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``data`或向量数据中的变量名称,可选
......@@ -39,15 +39,15 @@ seaborn.boxenplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`orient`:“v” &#124; “h”,可选
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
`color`:matplotlib颜色,可选
`color`:matplotlib 颜色,可选
> 所有元素的颜色,或渐变调色板的种子颜色。
`palette`:调色板名称,列表或字典,可选
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到 matplotlib 颜色的字典。
`saturation`:float,可选
......@@ -63,7 +63,7 @@ seaborn.boxenplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`k_depth`:“proportion” &#124; “tukey” &#124; “trustworthy”,可选
> 通过增大百分比的粒度控制绘制的盒形图数目。所有方法都在Wickham的论文中有详细描述。每个参数代表利用不同的统计特性对异常值的数量做出不同的假设。
> 通过增大百分比的粒度控制绘制的盒形图数目。所有方法都在 Wickham 的论文中有详细描述。每个参数代表利用不同的统计特性对异常值的数量做出不同的假设。
`linewidth`:float,可选
......@@ -75,26 +75,26 @@ seaborn.boxenplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`outlier_prop`:float,可选
> 被认为是异常值的数据比例。与 `k_depth` 结合使用以确定要绘制的百分位数。默认值为0.007作为异常值的比例。该参数取值应在[0,1]范围内。
> 被认为是异常值的数据比例。与 `k_depth` 结合使用以确定要绘制的百分位数。默认值为 0.007 作为异常值的比例。该参数取值应在[0,1]范围内。
`ax`:matplotlib轴,可选
`ax`:matplotlib 轴,可选
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
> 绘图时使用的 Axes 轴对象,否则使用当前 Axes 轴对象。
`kwargs`:键,值映射
> 其他在绘制时传递给`plt.plot`和`plt.scatter`参数。
返回值:`ax`:matplotlib轴
返回值:`ax`:matplotlib
> 返回Axes对轴象,并在其上绘制绘图。
> 返回 Axes 对轴象,并在其上绘制绘图。
亦可参见
boxplot和核密度估计的结合。一个传统的箱型图具有类似的API。
boxplot 和核密度估计的结合。一个传统的箱型图具有类似的 API。
示例
......@@ -119,7 +119,7 @@ boxplot和核密度估计的结合。一个传统的箱型图具有类似的API
![http://seaborn.pydata.org/_images/seaborn-boxenplot-2.png](img/31c79f0cf22d453e10799da960e3e801.jpg)
根据2个分类变量嵌套分组绘制一个增强箱型图:
根据 2 个分类变量嵌套分组绘制一个增强箱型图:
```py
>>> ax = sns.boxenplot(x="day", y="total_bill", hue="smoker",
......@@ -149,7 +149,7 @@ boxplot和核密度估计的结合。一个传统的箱型图具有类似的API
![http://seaborn.pydata.org/_images/seaborn-boxenplot-5.png](img/e8fa81696195ce058546e429317075bc.jpg)
针对DataFrame里每一个数值型变量绘制增强箱型图:
针对 DataFrame 里每一个数值型变量绘制增强箱型图:
```py
>>> iris = sns.load_dataset("iris")
......
......@@ -16,16 +16,16 @@ seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
输入数据可以通过多种格式传入,包括:
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 格式为列表,numpy 数组或 pandas Series 对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的 DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的 DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
在大多数情况下,可以使用 numpy 或 Python 对象,但更推荐使用 pandas 对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
更多信息请参阅 [教程](../tutorial/categorical.html#categorical-tutorial)
更多信息请参阅 [教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``data`或向量数据中的变量名称,可选
......@@ -37,7 +37,7 @@ seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`order, hue_order`:字符串列表,可选
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
`estimator`:调用函数实现向量 -&gt; 标量的映射,可选
......@@ -51,7 +51,7 @@ seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
> 计算置信区间时使用的引导迭代次数。
`units``data`vector data中变量的名称,可选
`units``data` vector data 中变量的名称,可选
> 采样单元的标识符,用于执行多级引导过程(计算置信区间等)并能够处理重复测量的设定。
......@@ -63,7 +63,7 @@ seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
> 用于每个`hue`色调的级别的线条风格。
`dodge`:boolfloat,可选
`dodge`:boolfloat,可选
> 用于沿着分类轴分离`hue`变量的每个级别数据点的数量。
......@@ -77,15 +77,15 @@ seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
`orient`:“v” &#124; “h”,可选
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的 dtype 推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
`color`:matplotlib颜色,可选
`color`:matplotlib 颜色,可选
> 所有元素的颜色,或渐变调色板的种子颜色。
`palette`:调色板名称,列表或字典,可选
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到 matplotlib 颜色的字典。
`errwidth`:float,可选
......@@ -95,14 +95,14 @@ seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=Non
> 误差线“上下限指示线”的宽度。
`ax`:matplotlib轴,可选
`ax`:matplotlib 轴,可选
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
> 绘图时使用的 Axes 轴对象,否则使用当前 Axes 轴对象。
返回值:`ax`:matplotlib轴
返回值:`ax`:matplotlib
> 返回Axes对轴象,并在其上绘制绘图。
> 返回 Axes 对轴象,并在其上绘制绘图。
......
......@@ -2,7 +2,7 @@
> 译者:[Neolei](https://github.com/neolei)
为了安装最新版本的seaborn, 可以 `pip`命令:
为了安装最新版本的 seaborn, 可以 `pip`命令:
```py
pip install seaborn
......@@ -14,13 +14,13 @@ pip install seaborn
conda install seaborn
```
或者,您可以使用 `pip` 直接从github安装开发版本:
或者,您可以使用 `pip` 直接从 github 安装开发版本:
```py
pip install git+https://github.com/mwaskom/seaborn.git
```
另外的方法是从 [github仓库](https://github.com/mwaskom/seaborn) 下载,从本地安装:
另外的方法是从 [github 仓库](https://github.com/mwaskom/seaborn) 下载,从本地安装:
```py
pip install .
......
# seaborn.barplot
> 译者:[melon-bun](https://github.com/melon-bun)
```py
seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, orient=None, color=None, palette=None, saturation=0.75, errcolor='.26', errwidth=None, capsize=None, dodge=True, ax=None, **kwargs)
```
条形图以矩形条的方式展示数据的点估值和置信区间
条形图用每个矩形的高度来表示数值变量的集中趋势的估计值,并提供误差条来显示估计值得不确定度。条形图的纵轴是从零开始的,这对于0值是有意义的情况是非常好的。
条形图用每个矩形的高度来表示数值变量的集中趋势的估计值,并提供误差条来显示估计值得不确定度。条形图的纵轴是从零开始的,这对于 0 值是有意义的情况是非常好的。
对于数据集中的0值没有实际意义的情况,散点图可以让您专注于一个或多个分类变量之间的差异。
对于数据集中的 0 值没有实际意义的情况,散点图可以让您专注于一个或多个分类变量之间的差异。
要注意的是,条形图只显示平均值(或者其他的估计值),但是在大部分情况下,展示数值在不同分类变量上的分布会更有用。如果要表示出数据的分布,用箱型图或者小提琴图会更恰当。
输入数据的格式可以不同,包括:
* 以列表,numpy array或者pandas中的Series object 表示的向量。这些向量可以直接传入 `x`, `y`, 以及 `hue` 参数。
* 长表, x值,y值和色相变量决定了数据是如何绘制的。
* 以列表,numpy array 或者 pandas 中的 Series object 表示的向量。这些向量可以直接传入 `x`, `y`, 以及 `hue` 参数。
* 长表, x 值,y 值和色相变量决定了数据是如何绘制的。
* 宽表,每个列的数值都会被绘制出来.
* 数组或者列表的向量。
大多数情况下,您可以使用numpy的对象或者python的对象,但是用pandas对象更好,因为相关的列名会被标注在图标上。 另外,为了控制绘图元素 您也可以可以用分类类型来组合不同的变量。
大多数情况下,您可以使用 numpy 的对象或者 python 的对象,但是用 pandas 对象更好,因为相关的列名会被标注在图标上。 另外,为了控制绘图元素 您也可以可以用分类类型来组合不同的变量。
这个函数始终把一个变量当做分类变量,即使这个数据是数值类型或者日期类型,并且按照序数顺序绘制在相关的轴上。
详情请看[教程](../tutorial/categorical.html#categorical-tutorial)
详情请看[教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue``data` 中的变量名词或者向量, optional
> 用于绘制long-form数据的变量名称.
> 用于绘制 long-form 数据的变量名称.
`data`:DataFrame, 数组, 数组列表, optional
> 用于绘图的数据集。如果数据集有x和y,数据集会被认为是long-form,否则会被认为是wide-form。
> 用于绘图的数据集。如果数据集有 x 和 y,数据集会被认为是 long-form,否则会被认为是 wide-form。
`order, hue_order`:字符串列表, optional
......@@ -43,15 +45,15 @@ seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
`ci`:float or “sd” or None, optional
> 估计值周围的置信区间大小。如果输入的是 “sd”(标准差),会跳过bootstrapping的过程,只绘制数据的标准差。 如果输入是的是`None`, 不会执行botstrapping,而且错误条也不会绘制。
> 估计值周围的置信区间大小。如果输入的是 “sd”(标准差),会跳过 bootstrapping 的过程,只绘制数据的标准差。 如果输入是的是`None`, 不会执行 botstrapping,而且错误条也不会绘制。
`n_boot`:int, optional
> 计算置信区间需要的Boostrap迭代次数。
> 计算置信区间需要的 Boostrap 迭代次数。
`units`:name of variable in `data` or vector data, optional
> 采样单元的标识符,用于执行多级bootstrap并解释重复测量设计。
> 采样单元的标识符,用于执行多级 bootstrap 并解释重复测量设计。
`orient`:“v” &#124; “h”, optional
......@@ -63,7 +65,7 @@ seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
`palette`:palette name, list, or dict, optional
> 不同级别的 `hue` 变量的颜色。 颜色要能被 [`color_palette()`]解释(seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 或者一个能映射到matplotlib颜色的字典。
> 不同级别的 `hue` 变量的颜色。 颜色要能被 [`color_palette()`]解释(seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 或者一个能映射到 matplotlib 颜色的字典。
`saturation`:float, optional
......@@ -87,7 +89,7 @@ seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
`ax`:matplotlib Axes, optional
> 指定一个Axes用于绘图,如果不指定,则使用当前的Axes。
> 指定一个 Axes 用于绘图,如果不指定,则使用当前的 Axes。
`kwargs`:key, value mappings
......@@ -95,13 +97,13 @@ seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
返回值:`ax`:matplotlib Axes
> 返回有图表绘制的Axes对象。
> 返回有图表绘制的 Axes 对象。
See also
显示每个分类bin中的观察计数。使用散点图图示符显示点估计和置信区间。将分类图与类相结合:<cite>FacetGrid</cite>.
显示每个分类 bin 中的观察计数。使用散点图图示符显示点估计和置信区间。将分类图与类相结合:<cite>FacetGrid</cite>.
Examples
......@@ -224,7 +226,7 @@ Examples
![http://seaborn.pydata.org/_images/seaborn-barplot-12.png](img/20114eb58ca40a3ccf0b20f14f426c83.jpg)
使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 来结合 [`barplot()`](#seaborn.barplot "seaborn.barplot")[`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之间保持同步:
使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 来结合 [`barplot()`](#seaborn.barplot "seaborn.barplot")[`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",
......
......@@ -6,22 +6,22 @@
seaborn.countplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, dodge=True, ax=None, **kwargs)
```
seaborn.countplot使用条形图显示每个类别中观测值的数量。
seaborn.countplot 使用条形图显示每个类别中观测值的数量。
这个函数可以被认为是针对类别变量的直方图。基本的API和选项与[`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot")完全相同,因此可以对比学习。
这个函数可以被认为是针对类别变量的直方图。基本的 API 和选项与[`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot")完全相同,因此可以对比学习。
可以通过多种格式传入数据,包括:
* 通过列表、numpy数组、或者pandas Series对象表示的向量数据,数据直接传给`x`, `y`, 和/或`hue`参数。
* 长格式的DataFrame,此时会通过`x`, `y`以及`hue`变量决定如何绘制数据。
* 宽格式的DataFrame,此时每个数值型的column都会被绘制。
* 通过列表、numpy 数组、或者 pandas Series 对象表示的向量数据,数据直接传给`x`, `y`, 和/或`hue`参数。
* 长格式的 DataFrame,此时会通过`x`, `y`以及`hue`变量决定如何绘制数据。
* 宽格式的 DataFrame,此时每个数值型的 column 都会被绘制。
* 数组或者列表形式的向量
在绝大多数情况下,数据格式都可以使用numpy或者Python对象,但是推荐使用pandas对象,因为pandas对象中相关的名称会被用于注释坐标轴。此外,可以通过设置分组变量为使用Categorical类型来控制绘制元素的顺序。
在绝大多数情况下,数据格式都可以使用 numpy 或者 Python 对象,但是推荐使用 pandas 对象,因为 pandas 对象中相关的名称会被用于注释坐标轴。此外,可以通过设置分组变量为使用 Categorical 类型来控制绘制元素的顺序。
这个函数总会将变量作为类别变量进行处理,按顺序(0, 1, ... n)在相应坐标轴绘制数据,即使数据为数值或者日期类型。
更多信息参考[tutorial](../tutorial/categorical.html#categorical-tutorial).
更多信息参考[tutorial](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial).
参数:`x, y, hue`: `data`或者向量数据中的变量名,可选
......@@ -37,15 +37,15 @@ seaborn.countplot使用条形图显示每个类别中观测值的数量。
`orient`: “v” &#124; “h”, 可选
> 绘制的朝向(竖直或者水平)。通过从输入变量的dtype进行推断。当类别变量是数值型或者绘制宽格式数据时,可以进行指定。
> 绘制的朝向(竖直或者水平)。通过从输入变量的 dtype 进行推断。当类别变量是数值型或者绘制宽格式数据时,可以进行指定。
`color`: matplotlib颜色,可选
`color`: matplotlib 颜色,可选
> 所有元素的颜色,或者渐变调色盘的种子。
`palette`: 调色盘名称,列表或字典,可选
> 用于`hue`变量的不同级别的颜色。应当是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。应当是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者将色调级别映射到 matplotlib 颜色的字典。
`saturation`: float, 可选
......@@ -55,7 +55,7 @@ seaborn.countplot使用条形图显示每个类别中观测值的数量。
> 当使用色调嵌套时,决定是否沿着类别轴对元素进行移位。
`ax`: matplotlib轴,可选
`ax`: matplotlib 轴,可选
> 绘制图像的轴对象,不指定时使用当前轴。
......@@ -64,7 +64,7 @@ seaborn.countplot使用条形图显示每个类别中观测值的数量。
> 其他关键字参数会被传递给`plt.bar`.
返回值:`ax`: matplotlib轴
返回值:`ax`: matplotlib
> 返回带有绘图的轴对象。
......
......@@ -10,23 +10,23 @@ seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, h
这个函数提供调用[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")类的便捷接口,以及一些封装好的绘图类型。这是一个轻量级的封装,如果需要更多的灵活性,应当直接使用[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid").
参数:`x, y`:strings或者vectors
参数:`x, y`:strings 或者 vectors
> `data`中的数据或者变量名。
`data`:DataFrame, 可选
> 当`x`和`y`为变量名时的DataFrame.
> 当`x`和`y`为变量名时的 DataFrame.
`kind`:{ “scatter” &#124; “reg” &#124; “resid” &#124; “kde” &#124; “hex” }, 可选
> 绘制图像的类型。
`stat_func`:可调用的,或者None, 可选
`stat_func`:可调用的,或者 None, 可选
> 已过时
`color`:matplotlib颜色, 可选
`color`:matplotlib 颜色, 可选
> 用于绘制元素的颜色。
......@@ -44,7 +44,7 @@ seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, h
`dropna`:bool, 可选
> 如果为True, 移除`x`和`y`中的缺失值。
> 如果为 True, 移除`x`和`y`中的缺失值。
`{x, y}lim`:two-tuples, 可选
......@@ -67,7 +67,7 @@ seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, h
参考
绘制图像的Grid类。如果需要更多的灵活性,可以直接使用Grid类。
绘制图像的 Grid 类。如果需要更多的灵活性,可以直接使用 Grid 类。
示例
......@@ -123,7 +123,7 @@ seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, h
![http://seaborn.pydata.org/_images/seaborn-jointplot-5.png](img/b6895c87c4fa5a7fa1dc151dc3e5b385.jpg)
不适用Pandas, 直接传输向量,随后给轴命名:
不适用 Pandas, 直接传输向量,随后给轴命名:
```py
>>> x, y = np.random.randn(2, 300)
......
# seaborn.pairplot
> 译者:[cancan233](https://github.com/cancan233)
```py
seaborn.pairplot(data, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind='scatter', diag_kind='auto', markers=None, height=2.5, aspect=1, dropna=True, plot_kws=None, diag_kws=None, grid_kws=None, size=None)
```
Plot pairwise relationships in a dataset.
By default, this function will create a grid of Axes such that each variable in `data` will by shared in the y-axis across a single row and in the x-axis across a single column. The diagonal Axes are treated differently, drawing a plot to show the univariate distribution of the data for the variable in that column.
绘制数据集中的成对关系
It is also possible to show a subset of variables or plot different variables on the rows and columns.
默认情况下,此函数将创建一个 Axes 网络,以便`data`中的每个变量将在 y 轴上共享一行,并在 x 轴上共享一列。对角轴的处理方式并不同,以此绘制一个图表来显示该列中变量的数据的单变量分布。
This is a high-level interface for [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") that is intended to make it easy to draw a few common styles. You should use [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") directly if you need more flexibility.
还可以显示变量的子集或在行和列上绘制不同的变量。
参数:`data`:DataFrame
这是[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")的高级界面,旨在简化一些常见的样式。如果你需要更多的灵活性,你应该直接使用[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")
> Tidy (long-form) dataframe where each column is a variable and each row is an observation.
参数:`data`:数据框架
`hue`:string (variable name), optional
> 整洁(长形式)数据框,其中每列是变量,每行是观察量。
> Variable in `data` to map plot aspects to different colors.
`hue`:字符串(变量名),可选。
`hue_order`:list of strings
> `data`中的变量将绘图方面映射到不同的颜色。
> Order for the levels of the hue variable in the palette
`hue_order`:字符串列表。
`palette`:dict or seaborn color palette
> 命令调色板中的色调变量的级别。
> Set of colors for mapping the `hue` variable. If a dict, keys should be values in the `hue` variable.
`palette`:字典或 seaborn 调色板。
`vars`:list of variable names, optional
> 用于映射`hue`变量的颜色集。如果是字典,关键字应该是`hue`变量中的值。
> Variables within `data` to use, otherwise use every column with a numeric datatype.
`vars`:变量名列表,可选。
`{x, y}_vars`:lists of variable names, optional
> 要使用的`data`中的变量,否则每一列使用数字的数据类型。
> Variables within `data` to use separately for the rows and columns of the figure; i.e. to make a non-square plot.
`{x, y}_vars`:变量名列表,可选。
`kind`:{‘scatter’, ‘reg’}, optional
> `data`中的变量分别用于图的行和列;即制作非方形图。
> Kind of plot for the non-identity relationships.
`kind`:{‘scatter’, ‘reg’}, 可选。
`diag_kind`:{‘auto’, ‘hist’, ‘kde’}, optional
> 一种非等同关系的图类型
> Kind of plot for the diagonal subplots. The default depends on whether `"hue"` is used or not.
`diag_kind`:{‘auto’, ‘hist’, ‘kde’}, 可选
`markers`:single matplotlib marker code or list, optional
> 对角线子图的一种图形。默认值取决于是否使用`hue`。
> Either the marker to use for all datapoints or a list of markers with a length the same as the number of levels in the hue variable so that differently colored points will also have different scatterplot markers.
`markers`:单个 matplotlit 标记代码或列表,可选
`height`:scalar, optional
> 要么是用于所有数据点的标记,要么是长度和色调变量中的级别数相同的标记列表,这样不同颜色的点也会有不同的散点图标记。
> Height (in inches) of each facet.
`height`:标量,可选。
`aspect`:scalar, optional
> 每个刻面的高度(以英寸为单位)
> Aspect * height gives the width (in inches) of each facet.
`aspect`:标量,可选。
`dropna`:boolean, optional
> Aspect\*height 给出每个刻面的宽度(以英寸为单位)
> Drop missing values from the data before plotting.
`dropna`:布尔值,可选。
`{plot, diag, grid}_kws`:dicts, optional
> 在绘图之前删除数据中的缺失值。
> Dictionaries of keyword arguments.
`{plot, diag, grid}_kws`:字典,可选。
> 关键字参数的字典。
返回值:`grid`:PairGrid
> Returns the underlying `PairGrid` instance for further tweaking.
> 返回底层的`PairGrid`实例以进一步调整。
See also
也可以看看
Subplot grid for more flexible plotting of pairwise relationships.
子图网络可以更灵活地绘制成对关系。
Examples
范例
Draw scatterplots for joint relationships and histograms for univariate distributions:
绘制联合关系地散点图和单变量分布的直方图:
```py
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
......@@ -88,7 +87,7 @@ Draw scatterplots for joint relationships and histograms for univariate distribu
![http://seaborn.pydata.org/_images/seaborn-pairplot-1.png](img/712c7f2cff4ed2c31b99bf5200838ae1.jpg)
Show different levels of a categorical variable by the color of plot elements:
通过绘图元素的颜色显示分类变量的不同级别:
```py
>>> g = sns.pairplot(iris, hue="species")
......@@ -97,7 +96,7 @@ Show different levels of a categorical variable by the color of plot elements:
![http://seaborn.pydata.org/_images/seaborn-pairplot-2.png](img/98c1e58e7427e940294084d2b4582ac8.jpg)
Use a different color palette:
使用不同的调色板:
```py
>>> g = sns.pairplot(iris, hue="species", palette="husl")
......@@ -106,7 +105,7 @@ Use a different color palette:
![http://seaborn.pydata.org/_images/seaborn-pairplot-3.png](img/f6d3d4030bc93eefcb054749cf90c36b.jpg)
Use different markers for each level of the hue variable:
`hue`变量的每个级别使用不同的标记:
```py
>>> g = sns.pairplot(iris, hue="species", markers=["o", "s", "D"])
......@@ -115,7 +114,7 @@ Use different markers for each level of the hue variable:
![http://seaborn.pydata.org/_images/seaborn-pairplot-4.png](img/6840daa5bd6d421f05969aeb76c74032.jpg)
Plot a subset of variables:
绘制变量的子集:
```py
>>> g = sns.pairplot(iris, vars=["sepal_width", "sepal_length"])
......@@ -124,7 +123,7 @@ Plot a subset of variables:
![http://seaborn.pydata.org/_images/seaborn-pairplot-5.png](img/87b11c84b7ec8551c2edf9a2ef987014.jpg)
Draw larger plots:
绘制更大的图:
```py
>>> g = sns.pairplot(iris, height=3,
......@@ -134,7 +133,7 @@ Draw larger plots:
![http://seaborn.pydata.org/_images/seaborn-pairplot-6.png](img/5e89b880399cf894d124b590416e7fb5.jpg)
Plot different variables in the rows and columns:
在行和列中绘制不同的变量:
```py
>>> g = sns.pairplot(iris,
......@@ -145,7 +144,7 @@ Plot different variables in the rows and columns:
![http://seaborn.pydata.org/_images/seaborn-pairplot-7.png](img/35f33d0939e4e10f46437f5690ad766b.jpg)
Use kernel density estimates for univariate plots:
对单变量图使用核密度估计:
```py
>>> g = sns.pairplot(iris, diag_kind="kde")
......@@ -154,7 +153,7 @@ Use kernel density estimates for univariate plots:
![http://seaborn.pydata.org/_images/seaborn-pairplot-8.png](img/cc2c3fb8414e50f2d9f95ab073457c23.jpg)
Fit linear regression models to the scatter plots:
将线性回归模型拟合到散点图:
```py
>>> g = sns.pairplot(iris, kind="reg")
......@@ -163,7 +162,7 @@ Fit linear regression models to the scatter plots:
![http://seaborn.pydata.org/_images/seaborn-pairplot-9.png](img/74befbc8e8cbc89474dd845fb49329ca.jpg)
Pass keyword arguments down to the underlying functions (it may be easier to use [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") directly):
将关键字参数传递给底层函数(直接使用[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")可能更容易)
```py
>>> g = sns.pairplot(iris, diag_kind="kde", markers="+",
......@@ -172,4 +171,4 @@ Pass keyword arguments down to the underlying functions (it may be easier to use
```
![http://seaborn.pydata.org/_images/seaborn-pairplot-10.png](img/0b688ef9f59240384ca84839d9707ce7.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-pairplot-10.png](img/0b688ef9f59240384ca84839d9707ce7.jpg)
......@@ -8,15 +8,15 @@ seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kw
灵活绘制单变量观测值分布图。
该函数结合了matplotlib中的 `hist`函数(自动计算一个默认的合适的bin大小)、seaborn的[`kdeplot()`](seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")[`rugplot()`](seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot")函数。它还可以拟合`scipy.stats`分布并在数据上绘制估计的PDF(概率分布函数)。
该函数结合了 matplotlib 中的 `hist`函数(自动计算一个默认的合适的 bin 大小)、seaborn 的[`kdeplot()`](seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")[`rugplot()`](seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot")函数。它还可以拟合`scipy.stats`分布并在数据上绘制估计的 PDF(概率分布函数)。
参数:`a`:Series、1维数组或者列表。
参数:`a`:Series、1 维数组或者列表。
> 观察数据。如果是具有`name`属性的Series对象,则该名称将用于标记数据轴。
> 观察数据。如果是具有`name`属性的 Series 对象,则该名称将用于标记数据轴。
`bins`:matplotlib hist()的参数,或None。可选参数。
`bins`:matplotlib hist()的参数,或 None。可选参数。
> 直方图bins(柱)的数目,若填None,则默认使用Freedman-Diaconis规则指定柱的数目。
> 直方图 bins(柱)的数目,若填 None,则默认使用 Freedman-Diaconis 规则指定柱的数目。
`hist`:布尔值,可选参数。
......@@ -32,7 +32,7 @@ seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kw
`fit`:随机变量对象,可选参数。
> 一个带有*fit*方法的对象,返回一个元组,该元组可以传递给*pdf*方法一个位置参数,该位置参数遵循一个值的网格用于评估pdf。
> 一个带有*fit*方法的对象,返回一个元组,该元组可以传递给*pdf*方法一个位置参数,该位置参数遵循一个值的网格用于评估 pdf。
`{hist, kde, rug, fit}_kws`:字典,可选参数。
......@@ -44,15 +44,15 @@ seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kw
`vertical`:布尔值,可选参数。
> 如果为True,则观测值在y轴显示。
> 如果为 True,则观测值在 y 轴显示。
`norm_hist`:布尔值,可选参数。
> 如果为True,则直方图的高度显示密度而不是计数。如果绘制KDE图或拟合密度,则默认为True。
> 如果为 True,则直方图的高度显示密度而不是计数。如果绘制 KDE 图或拟合密度,则默认为 True。
`axlabel`:字符串,False或者None,可选参数。
`axlabel`:字符串,False 或者 None,可选参数。
> 横轴的名称。如果为None,将尝试从a.name获取它;如果为False,则不设置标签。
> 横轴的名称。如果为 None,将尝试从 a.name 获取它;如果为 False,则不设置标签。
`label`:字符串,可选参数。
......@@ -64,7 +64,7 @@ seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kw
返回值:`ax`:matplotlib Axes
> 返回Axes对象以及用于进一步调整的绘图。
> 返回 Axes 对象以及用于进一步调整的绘图。
**另请参见**
......@@ -78,7 +78,7 @@ seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kw
**范例**
显示具有核密度估计的默认图和使用参考规则自动确定bin大小的直方图:
显示具有核密度估计的默认图和使用参考规则自动确定 bin 大小的直方图:
```py
>>> import seaborn as sns, numpy as np
>>> sns.set(); np.random.seed(0)
......@@ -88,7 +88,7 @@ seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kw
```
![http://seaborn.pydata.org/_images/seaborn-distplot-1.png](img/dfbc2ec93ea21c479448cd2e25976945.jpg)
使用Pandas对象获取信息轴标签:
使用 Pandas 对象获取信息轴标签:
```py
>>> import pandas as pd
......
......@@ -14,19 +14,19 @@ seaborn.kdeplot(data, data2=None, shade=False, vertical=False, kernel='gau', bw=
**data2:一维阵列,可选。
> 第二输入数据。如果存在,将估计双变量KDE。
> 第二输入数据。如果存在,将估计双变量 KDE。
`shade`:布尔值,可选参数。
> 如果为True,则在KDE曲线下方的区域中增加阴影(或者在数据为双变量时使用填充的轮廓绘制)。
> 如果为 True,则在 KDE 曲线下方的区域中增加阴影(或者在数据为双变量时使用填充的轮廓绘制)。
`vertical`:布尔值,可选参数。
> 如果为True,密度图将显示在x轴。
> 如果为 True,密度图将显示在 x 轴。
`kernel`:{‘gau’ &#124; ‘cos’ &#124; ‘biw’ &#124; ‘epa’ &#124; ‘tri’ &#124; ‘triw’ },可选参数
> 要拟合的核的形状代码,双变量KDE只能使用高斯核。
> 要拟合的核的形状代码,双变量 KDE 只能使用高斯核。
`bw`:{‘scott’ &#124; ‘silverman’ &#124; scalar &#124; pair of scalars },可选参数
......@@ -42,23 +42,23 @@ seaborn.kdeplot(data, data2=None, shade=False, vertical=False, kernel='gau', bw=
`clip`:一对标量,可选参数。
> 用于拟合KDE图的数据点的上下限值。可以为双变量图提供一对(上,下)边界。
> 用于拟合 KDE 图的数据点的上下限值。可以为双变量图提供一对(上,下)边界。
`legend`:布尔值,可选参数。
> 如果为True,为绘制的图像添加图例或者标记坐标轴。
> 如果为 True,为绘制的图像添加图例或者标记坐标轴。
`cumulative`:布尔值,可选参数。
> 如果为True,则绘制kde估计图的累积分布。
> 如果为 True,则绘制 kde 估计图的累积分布。
`shade_lowest`:布尔值,可选参数。
> 如果为True,则屏蔽双变量KDE图的最低轮廓。绘制单变量图或“shade = False”时无影响。当你想要在同一轴上绘制多个密度时,可将此参数设置为“False”。
> 如果为 True,则屏蔽双变量 KDE 图的最低轮廓。绘制单变量图或“shade = False”时无影响。当你想要在同一轴上绘制多个密度时,可将此参数设置为“False”。
`cbar`:布尔值,可选参数。
> 如果为True并绘制双变量KDE图,为绘制的图像添加颜色条。
> 如果为 True 并绘制双变量 KDE 图,为绘制的图像添加颜色条。
`cbar_ax`:matplotlib axes,可选参数。
......
......@@ -10,7 +10,7 @@ seaborn.rugplot(a, height=0.05, axis='x', ax=None, **kwargs)
参数:`a`:向量
> 1维的观察数组。
> 1 维的观察数组。
`height`:标量, 可选
......@@ -18,7 +18,7 @@ seaborn.rugplot(a, height=0.05, axis='x', ax=None, **kwargs)
`axis`:{‘x’ &#124; ‘y’}, 可选
> 需要画rugplot的坐标轴
> 需要画 rugplot 的坐标轴
`ax`:matplotlib 轴, 可选
......@@ -29,7 +29,7 @@ seaborn.rugplot(a, height=0.05, axis='x', ax=None, **kwargs)
> 被传递给`LineCollection`的其他关键字参数。
返回值:`ax`:matplotlib Axex对象
返回值:`ax`:matplotlib Axex 对象
> 在其上进行绘图的Axex对象。
> 在其上进行绘图的 Axex 对象。
......@@ -6,13 +6,13 @@
seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=None, height=5, aspect=1, markers='o', sharex=True, sharey=True, hue_order=None, col_order=None, row_order=None, legend=True, legend_out=True, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, x_partial=None, y_partial=None, truncate=False, x_jitter=None, y_jitter=None, scatter_kws=None, line_kws=None, size=None)
```
FacetGrid对象上绘制数据和回归模型。
FacetGrid 对象上绘制数据和回归模型。
这个函数结合了 [`regplot()`](seaborn.regplot.html#seaborn.regplot "seaborn.regplot")[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")。 它预期作为一个能够将回归模型运用在数据集处于不同条件下的子数据集的方便的接口
在考虑如何将变量分配到不同方面时,一般规则是使用 `hue` 进行最重要的比较,然后使用 `col``row `。 但是,请始终考虑您的特定数据集以及您正在创建的可视化目标。
估算回归模型有许多互斥的选项。 有关详细信息,请参阅 [tutorial](../tutorial/regression.html#regression-tutorial)
估算回归模型有许多互斥的选项。 有关详细信息,请参阅 [tutorial](http://seaborn.pydata.org/tutorial/regression.html#regression-tutorial)
此函数的参数涵盖了 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")中的大多数选项,尽管这样,偶尔还是会出现您需要直接使用该类和 [`regplot()`](seaborn.regplot.html#seaborn.regplot "seaborn.regplot") 的情况。
......@@ -22,7 +22,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
`data`:DataFrame
> Tidy (“long-form”)格式的DataFrame,其中每列为一个变量,每行为一个观测样本。
> Tidy (“long-form”)格式的 DataFrame,其中每列为一个变量,每行为一个观测样本。
`hue, col, row`:字符串
......@@ -30,7 +30,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
`palette`: 调色板名称,列表或字典,可选
> 用于`hue`变量的不同级别的颜色。 应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> 用于`hue`变量的不同级别的颜色。 应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者是将色调级别映射到 matplotlib 颜色的字典。
`col_wrap`:整数,可选
......@@ -44,17 +44,17 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
> 每个分面(facet)的纵横比,因此`aspect * height`给出每个分面(facet)的宽度,单位为英寸。
`markers`:matplotlib标记代码或标记代码列表,可选
`markers`:matplotlib 标记代码或标记代码列表,可选
> 散点图的标记。如果是列表,列表中的每个标记将用于`hue`变量的每个级别。
`share{x,y}`:布尔值,‘col’,或 ‘row’ ,可选
> 如果为true,则分面(facet)之间将跨列共享y轴和/或跨行共享x轴。
> 如果为 true,则分面(facet)之间将跨列共享 y 轴和/或跨行共享 x 轴。
`{hue,col,row}_order`:列表,可选
> 分面变量的级别顺序。在默认情况下,这将是级别在“data”中出现的顺序,或者,如果变量是pandas的分类类别变量,则为类别的顺序。
> 分面变量的级别顺序。在默认情况下,这将是级别在“data”中出现的顺序,或者,如果变量是 pandas 的分类类别变量,则为类别的顺序。
`legend`:布尔值,可选
......@@ -72,9 +72,9 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
> 将`x`变量加入离散区间,然后估计中心趋势和置信区间。 此分箱仅影响散点图的绘制方式; 回归仍然适合原始数据。该参数被解释为均匀大小(不必要间隔)的箱的数量或箱中心的位置。使用此参数时,它意味着`x_estimator`的默认值为`numpy.mean`。
`x_ci`:“ci”。“sd”, 在[0,100]间的整数或None,可选
`x_ci`:“ci”。“sd”, 在[0,100]间的整数或 None,可选
> 绘制“x”离散值的集中趋势时使用的置信区间的大小。 如果为`“ci”`,遵循`ci`参数的值。 如果是“sd”,则跳过bootstrapping并显示每个bin中观察值的标准偏差。
> 绘制“x”离散值的集中趋势时使用的置信区间的大小。 如果为`“ci”`,遵循`ci`参数的值。 如果是“sd”,则跳过 bootstrapping 并显示每个 bin 中观察值的标准偏差。
`scatter`:布尔值,可选
......@@ -84,9 +84,9 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
> 如果为 `True`,则估计并绘制与 `x` 和 `y` 变量相关的回归模型。
`ci`:在[0,100]间的整数或None,可选
`ci`:在[0,100]间的整数或 None,可选
> 回归估计的置信区间的大小。这将使用回归线周围的半透明带绘制。 使用自助法(bootstrap)估计置信区间; 对于大型数据集,建议通过将此参数设置为None来避免该计算。
> 回归估计的置信区间的大小。这将使用回归线周围的半透明带绘制。 使用自助法(bootstrap)估计置信区间; 对于大型数据集,建议通过将此参数设置为 None 来避免该计算。
`n_boot`:整数,可选
......@@ -98,7 +98,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
`order`:整数,可选
> 如果`order`大于1,使用`numpy.polyfit`来估计多项式回归。
> 如果`order`大于 1,使用`numpy.polyfit`来估计多项式回归。
`logistic`:布尔值,可选
......@@ -106,7 +106,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
`lowess`:布尔值,可选
> 如果为“True”,则使用`statsmodels`来估计非参数lowess模型(局部加权线性回归)。 请注意,目前无法为此类模型绘制置信区间。
> 如果为“True”,则使用`statsmodels`来估计非参数 lowess 模型(局部加权线性回归)。 请注意,目前无法为此类模型绘制置信区间。
`robust`:布尔值,可选
......@@ -114,7 +114,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
`logx`:布尔值,可选
> 如果为 `True`,则估计形式y~log(x)的线性回归,但在输入空间中绘制散点图和回归模型。 请注意,`x`必须为正才能正常工作。
> 如果为 `True`,则估计形式 y~log(x)的线性回归,但在输入空间中绘制散点图和回归模型。 请注意,`x`必须为正才能正常工作。
`{x,y}_partial``data`中的字符串或矩阵
......@@ -122,7 +122,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
`truncate`:布尔值,可选
> 默认情况下,绘制回归线以在绘制散点图后填充x轴限制。 如果`truncate`是`True`,它将改为受到数据本身限制的限制。
> 默认情况下,绘制回归线以在绘制散点图后填充 x 轴限制。 如果`truncate`是`True`,它将改为受到数据本身限制的限制。
`{x,y}_jitter`:浮点数,可选
......@@ -136,7 +136,7 @@ seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=
也可以查看
绘制数据和条件模型fit.Subplot网格用于绘制条件关系。合并 [`regplot()`](seaborn.regplot.html#seaborn.regplot "seaborn.regplot")[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") (与`kind =“reg”`一起使用时)。
绘制数据和条件模型 fit.Subplot 网格用于绘制条件关系。合并 [`regplot()`](seaborn.regplot.html#seaborn.regplot "seaborn.regplot")[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") (与`kind =“reg”`一起使用时)。
注意
......
......@@ -8,15 +8,15 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
绘制数据和线性回归模型拟合。
估算回归模型有许多互斥的选项。查看这个[教程](../tutorial/regression.html#regression-tutorial) 来了解更多的信息。
估算回归模型有许多互斥的选项。查看这个[教程](http://seaborn.pydata.org/tutorial/regression.html#regression-tutorial) 来了解更多的信息。
参数:**x,y:字符串,序列(series)或者是向量数组(vector array)**
> 输入变量。 如果是字符串,应该与`data`中的列名相对应。 使用pandas对象时,轴将被Series的名字标记。
> 输入变量。 如果是字符串,应该与`data`中的列名相对应。 使用 pandas 对象时,轴将被 Series 的名字标记。
`data`:DataFrame
> Tidy (“long-form”)格式的DataFrame,其中每列为一个变量,每行为一个观测样本。
> Tidy (“long-form”)格式的 DataFrame,其中每列为一个变量,每行为一个观测样本。
`x_estimator`:可调用的映射向量 -&gt;标量,可选
......@@ -26,9 +26,9 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
> 将`x`变量加入离散区间,然后估计中心趋势和置信区间。 此分箱仅影响散点图的绘制方式; 回归仍然适合原始数据。该参数被解释为均匀大小(不必要间隔)的箱的数量或箱中心的位置。使用此参数时,它意味着`x_estimator`的默认值为`numpy.mean`。
`x_ci`:"ci",'sd',位于 [0, 100]之间的整数或None,可选
`x_ci`:"ci",'sd',位于 [0, 100]之间的整数或 None,可选
> 绘制“x”离散值的集中趋势时使用的置信区间的大小。 如果为`“ci”`,遵循`ci`参数的值。 如果是“sd”,则跳过bootstrapping并显示每个bin中观察值的标准偏差。
> 绘制“x”离散值的集中趋势时使用的置信区间的大小。 如果为`“ci”`,遵循`ci`参数的值。 如果是“sd”,则跳过 bootstrapping 并显示每个 bin 中观察值的标准偏差。
`scatter`:布尔值,可选
......@@ -38,9 +38,9 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
> 如果为 `True`,则估计并绘制与 `x` 和 `y` 变量相关的回归模型。
`ci`:位于 [0, 100]之间的整数或None,可选
`ci`:位于 [0, 100]之间的整数或 None,可选
> 回归估计的置信区间的大小。这将使用回归线周围的半透明带绘制。 使用自助法(bootstrap)估计置信区间; 对于大型数据集,建议通过将此参数设置为None来避免该计算。
> 回归估计的置信区间的大小。这将使用回归线周围的半透明带绘制。 使用自助法(bootstrap)估计置信区间; 对于大型数据集,建议通过将此参数设置为 None 来避免该计算。
`n_boot`:整数,可选
......@@ -52,7 +52,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
`order`:整数,可选
> 如果`order`大于1,使用`numpy.polyfit`来估计多项式回归。
> 如果`order`大于 1,使用`numpy.polyfit`来估计多项式回归。
`logistic`:布尔值,可选
......@@ -60,7 +60,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
`lowess`:布尔值,可选
> 如果为“True”,则使用`statsmodels`来估计非参数lowess模型(局部加权线性回归)。 请注意,目前无法为此类模型绘制置信区间。
> 如果为“True”,则使用`statsmodels`来估计非参数 lowess 模型(局部加权线性回归)。 请注意,目前无法为此类模型绘制置信区间。
`robust`:布尔值,可选
......@@ -68,7 +68,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
`logx`:布尔值,可选
> 如果为 `True`,则估计形式y~log(x)的线性回归,但在输入空间中绘制散点图和回归模型。 请注意,`x`必须为正才能正常工作。
> 如果为 `True`,则估计形式 y~log(x)的线性回归,但在输入空间中绘制散点图和回归模型。 请注意,`x`必须为正才能正常工作。
`{x,y}_partial``data` 中的字符串或矩阵
......@@ -76,7 +76,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
`truncate`:布尔值,可选
> 默认情况下,绘制回归线以在绘制散点图后填充x轴限制。 如果`truncate`是`True`,它将改为受到数据本身限制的限制。
> 默认情况下,绘制回归线以在绘制散点图后填充 x 轴限制。 如果`truncate`是`True`,它将改为受到数据本身限制的限制。
`{x,y}_jitter`:浮点数,可选
......@@ -90,7 +90,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
> 适用于所有绘图元素的颜色; 将被`scatter_kws`或`line_kws`中传递的颜色取代。
`marker`:matplotlib标记代码或标记代码列表,可选
`marker`:matplotlib 标记代码或标记代码列表,可选
> 散点图的标记。
......@@ -98,14 +98,14 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
> 传递给`plt.scatter`和`plt.plot`的附加关键字参数。
`ax`:matplotlib Axes对象,可选
`ax`:matplotlib Axes 对象,可选
> 绘制到指定轴对象,否则在当前轴对象上绘图。
返回值:`ax`:matplotlib Axes对象
返回值:`ax`:matplotlib Axes 对象
> 包含了图像的Axes对象。
> 包含了图像的 Axes 对象。
......@@ -121,7 +121,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
例子
绘制DataFrame中两个变量之间的关系:
绘制 DataFrame 中两个变量之间的关系:
```py
>>> import seaborn as sns; sns.set(color_codes=True)
......@@ -132,7 +132,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
![http://seaborn.pydata.org/_images/seaborn-regplot-1.png](img/99b1873131479cf9f24377991b06cbdb.jpg)
利用两个定义为numpy数组的变量进行绘图; 使用不同的颜色:
利用两个定义为 numpy 数组的变量进行绘图; 使用不同的颜色:
```py
>>> import numpy as np; np.random.seed(8)
......@@ -144,7 +144,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
![http://seaborn.pydata.org/_images/seaborn-regplot-2.png](img/b6422e805157f85b21973dd3266dcb3f.jpg)
利用两个定义为pandas Series的变量来进行绘图; 使用不同的标记:
利用两个定义为 pandas Series 的变量来进行绘图; 使用不同的标记:
```py
>>> import pandas as pd
......@@ -155,7 +155,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
![http://seaborn.pydata.org/_images/seaborn-regplot-3.png](img/2749fd423c61cc0419daeeec8d8aa467.jpg)
使用68%置信区间,该区间对应于估计的标准误差:
使用 68%置信区间,该区间对应于估计的标准误差:
```py
>>> ax = sns.regplot(x=x, y=y, ci=68)
......@@ -215,7 +215,7 @@ seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatt
![http://seaborn.pydata.org/_images/seaborn-regplot-9.png](img/83369998db2c4eb1e99c856c538f5cb2.jpg)
对数据运用逻辑回归; 抖动y变量并使用较少的bootstrap迭代:
对数据运用逻辑回归; 抖动 y 变量并使用较少的 bootstrap 迭代:
```py
>>> tips["big_tip"] = (tips.tip / tips.total_bill) > .175
......
......@@ -8,7 +8,7 @@ seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None,
绘制线性回归的残差。
此函数将在x上回归y(可能作为鲁棒或多项式回归),然后绘制残差的散点图。 你可以选择将局部加权回归散点平滑法(LOWESS)拟合到残差图,这有助于确定残差是否存在结构。
此函数将在 x 上回归 y(可能作为鲁棒或多项式回归),然后绘制残差的散点图。 你可以选择将局部加权回归散点平滑法(LOWESS)拟合到残差图,这有助于确定残差是否存在结构。
参数:`x`: 向量或字符串
......@@ -20,7 +20,7 @@ seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None,
`data`:DataFrame, 可选
> 如果 *x* 和 *y* 是列名,则指定使用的DataFrame
> 如果 *x* 和 *y* 是列名,则指定使用的 DataFrame
`lowess`: 布尔值, 可选
......@@ -28,7 +28,7 @@ seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None,
`{x, y}_partial`:矩阵或字符串,可选
> 具有与x相同的第一维的矩阵或数据中的列名称。这些变量被视为有误的,并在绘制之前从x或y变量中删除。
> 具有与 x 相同的第一维的矩阵或数据中的列名称。这些变量被视为有误的,并在绘制之前从 x 或 y 变量中删除。
`order`:整数,可选
......@@ -40,7 +40,7 @@ seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None,
`dropna`:布尔值,可选
> 如果为True,则在拟合和绘图时忽略缺少的数据。
> 如果为 True,则在拟合和绘图时忽略缺少的数据。
`label`:字符串,可选
......@@ -54,12 +54,12 @@ seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None,
> 用于绘制图像的组件而传递给 scatter() 和 plot() 的其他关键字参数。
`ax`:matplotlib轴,可选
`ax`:matplotlib 轴,可选
> 绘制到指定轴对象,否则在当前轴对象上绘图,如果轴不存在则创建一个新轴。
返回值:ax:matplotlib Axes对象
返回值:ax:matplotlib Axes 对象
> 带有回归图像的轴对象
......
......@@ -4,7 +4,7 @@
统计分析是了解数据集中的变量如何相互关联以及这些关系如何依赖于其他变量的过程。可视化是此过程的核心组件,这是因为当数据被恰当地可视化时,人的视觉系统可以看到指示关系的趋势和模式。
我们将在本教程中讨论三个seaborn函数。我们最常用的是[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")。这是一个[figure-level](../introduction.html#intro-func-types)的函数,可以用散点图和线图两种通用的方法来可视化统计关系。[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 与两个[axes-level]()函数组合在一起:
我们将在本教程中讨论三个 seaborn 函数。我们最常用的是[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")。这是一个[figure-level](../introduction.html#intro-func-types)的函数,可以用散点图和线图两种通用的方法来可视化统计关系。[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 与两个[axes-level]()函数组合在一起:
* [`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot") (`kind="scatter"`; 默认值)
* [`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")(`kind="line"`)
......@@ -24,7 +24,7 @@ sns.set(style="darkgrid")
散点图是数据可视化的支柱,它通过点云描绘了两个变量的联合分布,其中每个点代表数据集中的一个观测值。这种描述能够使我们通过视觉推断出许多信息,他们之间是否存在任何有意义的关系。
seaborn中有多种方式绘制散点图。当两个变量的是数值型时,最基本的是函数[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")。在 [类别可视化](categorical.html#categorical-tutorial),我们将会看到使用散点图来显示类别数据的专用工具。[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")`kind`的默认类型(也可以通过`kind="scatter"`来设置):
seaborn 中有多种方式绘制散点图。当两个变量的是数值型时,最基本的是函数[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")。在 [类别可视化](categorical.html#categorical-tutorial),我们将会看到使用散点图来显示类别数据的专用工具。[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")`kind`的默认类型(也可以通过`kind="scatter"`来设置):
```py
tips = sns.load_dataset("tips")
......@@ -34,7 +34,7 @@ sns.relplot(x="total_bill", y="tip", data=tips);
![http://seaborn.pydata.org/_images/relational_4_0.png](img/da2b66e95b2bbd08f2c58046234e97b1.jpg)
虽然这些点是以二维绘制的,但可以通过根据第三个变量对点进行着色来将另一个维度添加到绘图中。在seaborn中,这被称为使用“色调语义”,因为该点的颜色获得了意义:
虽然这些点是以二维绘制的,但可以通过根据第三个变量对点进行着色来将另一个维度添加到绘图中。在 seaborn 中,这被称为使用“色调语义”,因为该点的颜色获得了意义:
```py
......@@ -101,14 +101,14 @@ sns.relplot(x="total_bill", y="tip", size="size", sizes=(15, 200), data=tips);
![http://seaborn.pydata.org/_images/relational_18_0.png](img/c622412b599649be9b4d765223de73f5.jpg)
[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")API示例中展示了更多如何通过自定义使用不同语义来显示统计关系的示例。
[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")API 示例中展示了更多如何通过自定义使用不同语义来显示统计关系的示例。
## 强调线图的连续性
散点图是非常有效的,但是没有通用的最优可视化类型。相反,可视表示应该适应数据集的细节以及您试图用图表回答的问题。
对于某些数据集,您可能希望了解一个变量中的变化关于时间的函数,或者类似的连续变量。在这种情况下,一个很好的选择是绘制线图。
seaborn中,这可以通过[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")函数直接实现,也可以通过设置[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")的参数`kind="line"`来实现:
seaborn 中,这可以通过[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")函数直接实现,也可以通过设置[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")的参数`kind="line"`来实现:
```py
df = pd.DataFrame(dict(time=np.arange(500),
......@@ -132,7 +132,7 @@ sns.relplot(x="x", y="y", sort=False, kind="line", data=df);
### 聚合和表示不确定性
更复杂的数据集将对`x`变量的相同值有多个观测值。seaborn的默认行为是通过绘制平均值及95%的置信区间,在每个`x`周围聚合多个测量值:
更复杂的数据集将对`x`变量的相同值有多个观测值。seaborn 的默认行为是通过绘制平均值及 95%的置信区间,在每个`x`周围聚合多个测量值:
```py
fmri = sns.load_dataset("fmri")
......@@ -142,7 +142,7 @@ sns.relplot(x="timepoint", y="signal", kind="line", data=fmri);
![http://seaborn.pydata.org/_images/relational_25_0.png](img/c1b2a3e1708607a80c705b690a9c6c5a.jpg)
置信区间是使用bootstrapping计算的,对于较大的数据集,它可能是时间密集型的。因此,可以禁用它们:
置信区间是使用 bootstrapping 计算的,对于较大的数据集,它可能是时间密集型的。因此,可以禁用它们:
```py
sns.relplot(x="timepoint", y="signal", ci=None, kind="line", data=fmri);
......@@ -171,7 +171,7 @@ sns.relplot(x="timepoint", y="signal", estimator=None, kind="line", data=fmri);
### Plotting subsets of data with semantic mappings
函数[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")具有相同的灵活性:它可以通过修改绘图元素的色调,大小和样式来显示最多三个附加变量。它使用于[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")相同的API,这意味着我们不需要停下来考虑控制matplotlib中线条与点外观的参数。
函数[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")具有相同的灵活性:它可以通过修改绘图元素的色调,大小和样式来显示最多三个附加变量。它使用于[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")相同的 API,这意味着我们不需要停下来考虑控制 matplotlib 中线条与点外观的参数。
[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")中使用语义也将决定数据的聚合方式。例如,添加具有两个级别的色调语义将绘图分成两行以及错误带,每个都着色以指示它们对应于哪个数据集。
......@@ -287,7 +287,7 @@ sns.relplot(x="time", y="firing_rate",
### 用日期数据绘图
线图通常用于可视化与实际日期和时间相关的数据。这些函数以原始格式将数据传递给底层的matplotlib函数,因此他们可以利用matplotlib在tick标签中设置日期格式的功能。但是所有这些格式化都必须在matplotlib层进行,您应该参考matplotlib文档来了解它是如何工作的:
线图通常用于可视化与实际日期和时间相关的数据。这些函数以原始格式将数据传递给底层的 matplotlib 函数,因此他们可以利用 matplotlib 在 tick 标签中设置日期格式的功能。但是所有这些格式化都必须在 matplotlib 层进行,您应该参考 matplotlib 文档来了解它是如何工作的:
```py
df = pd.DataFrame(dict(time=pd.date_range("2017-1-1", periods=500),
......
......@@ -8,11 +8,11 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
将矩形数据绘制为颜色编码矩阵。
这是一个坐标轴级的函数,如果没有提供给`ax`参数,它会将热力图绘制到当前活动的轴中。除非`cbar`False或为`cbar_ax`提供单独的Axes,否则将使用此轴空间的一部分绘制颜色图。
这是一个坐标轴级的函数,如果没有提供给`ax`参数,它会将热力图绘制到当前活动的轴中。除非`cbar` False 或为`cbar_ax`提供单独的 Axes,否则将使用此轴空间的一部分绘制颜色图。
参数:`data`:矩形数据集
> 可以强制转换为ndarray格式数据的2维数据集。如果提供了Pandas DataFrame数据,索引/列信息将用于标记列和行。
> 可以强制转换为 ndarray 格式数据的 2 维数据集。如果提供了 Pandas DataFrame 数据,索引/列信息将用于标记列和行。
`vmin, vmax`:浮点型数据,可选参数。
......@@ -28,11 +28,11 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
`robust`:布尔值,可选参数。
> 如果是True,并且`vmin`或`vmax`为空,则使用稳健分位数而不是极值来计算色彩映射范围。
> 如果是 True,并且`vmin`或`vmax`为空,则使用稳健分位数而不是极值来计算色彩映射范围。
`annot`:布尔值或者矩形数据,可选参数。
> 如果为True,则在每个热力图单元格中写入数据值。 如果数组的形状与`data`相同,则使用它来代替原始数据注释热力图。
> 如果为 True,则在每个热力图单元格中写入数据值。 如果数组的形状与`data`相同,则使用它来代替原始数据注释热力图。
`fmt`:字符串,可选参数。
......@@ -40,7 +40,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
`annot_kws`:字典或者键值对,可选参数。
> 当`annot`为True时,`ax.text`的关键字参数。
> 当`annot`为 True 时,`ax.text`的关键字参数。
`linewidths`:浮点数,可选参数。
......@@ -64,15 +64,15 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
`square`:布尔值,可选参数。
> 如果为True,则将坐标轴方向设置为“equal”,以使每个单元格为方形。
> 如果为 True,则将坐标轴方向设置为“equal”,以使每个单元格为方形。
`xticklabels, yticklabels`:“auto”,布尔值,类列表值,或者整形数值,可选参数。
> 如果为True,则绘制数据框的列名称。如果为False,则不绘制列名称。如果是列表,则将这些替代标签绘制为xticklabels。如果是整数,则使用列名称,但仅绘制每个n标签。如果是“auto”,将尝试密集绘制不重叠的标签。
> 如果为 True,则绘制数据框的列名称。如果为 False,则不绘制列名称。如果是列表,则将这些替代标签绘制为 xticklabels。如果是整数,则使用列名称,但仅绘制每个 n 标签。如果是“auto”,将尝试密集绘制不重叠的标签。
`mask`:布尔数组或者DataFrame数据,可选参数。
`mask`:布尔数组或者 DataFrame 数据,可选参数。
> 如果为空值,数据将不会显示在`mask`为True的单元格中。 具有缺失值的单元格将自动被屏蔽。
> 如果为空值,数据将不会显示在`mask`为 True 的单元格中。 具有缺失值的单元格将自动被屏蔽。
`ax`:matplotlib Axes,可选参数。
......@@ -94,7 +94,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
范例
numpy数组绘制热力图:
numpy 数组绘制热力图:
```py
>>> import numpy as np; np.random.seed(0)
......@@ -106,7 +106,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
![http://seaborn.pydata.org/_images/seaborn-heatmap-1.png](img/2dcc622657bb409719bb9c747e0456c4.jpg)
更改默认的colormap范围:
更改默认的 colormap 范围:
```py
>>> ax = sns.heatmap(uniform_data, vmin=0, vmax=1)
......@@ -115,7 +115,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
![http://seaborn.pydata.org/_images/seaborn-heatmap-2.png](img/6600f3e11ba368f49ec94d562dd39b4a.jpg)
使用发散色图绘制以0为中心的数据的热力图:
使用发散色图绘制以 0 为中心的数据的热力图:
```py
>>> normal_data = np.random.randn(10, 12)
......@@ -125,7 +125,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
![http://seaborn.pydata.org/_images/seaborn-heatmap-3.png](img/519a9ac2d3daa6dd6160e4f71bf0e342.jpg)
使用特定的行和列标签绘制dataframe:
使用特定的行和列标签绘制 dataframe:
```py
>>> flights = sns.load_dataset("flights")
......@@ -154,7 +154,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
![http://seaborn.pydata.org/_images/seaborn-heatmap-6.png](img/970cf8333ec7a6b8eec115254ad34265.jpg)
使用不同的colormap:
使用不同的 colormap:
```py
>>> ax = sns.heatmap(flights, cmap="YlGnBu")
......@@ -163,7 +163,7 @@ seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False
![http://seaborn.pydata.org/_images/seaborn-heatmap-7.png](img/e18cb02ed3ad1b91b540951f2912539b.jpg)
colormap置于特定值的中心:
colormap 置于特定值的中心:
```py
>>> ax = sns.heatmap(flights, center=flights.loc["January", 1955])
......
# seaborn.clustermap
> 译者:[cancan233](https://github.com/cancan233)
```py
seaborn.clustermap(data, pivot_kws=None, method='average', metric='euclidean', z_score=None, standard_scale=None, figsize=None, cbar_kws=None, row_cluster=True, col_cluster=True, row_linkage=None, col_linkage=None, row_colors=None, col_colors=None, mask=None, **kwargs)
```
Plot a matrix dataset as a hierarchically-clustered heatmap.
将矩阵数据集绘制成分层聚类热图。
参数:**data:2D array-like**
> Rectangular data for clustering. Cannot contain NAs.
> 用于聚类的矩形数据,不能包含 NA。
`pivot_kws`dict, optional
`pivot_kws`字典,可选。
> If &lt;cite&gt;data&lt;/cite&gt; is a tidy dataframe, can provide keyword arguments for pivot to create a rectangular dataframe.
> 如果数据是整齐的数据框架,可以为 pivot 提供关键字参数以创建矩形数据框架。
`method`str, optional
`method`字符串,可选。
> Linkage method to use for calculating clusters. See scipy.cluster.hierarchy.linkage documentation for more information: [https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)
> 用于计算聚类的链接方法。有关更多信息,请参阅文档 scipy.cluster.hierarchy.linkage [https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)
`metric`str, optional
`metric`字符串,可选。
> Distance metric to use for the data. See scipy.spatial.distance.pdist documentation for more options [https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html) To use different metrics (or methods) for rows and columns, you may construct each linkage matrix yourself and provide them as {row,col}_linkage.
> 用于数据的距离度量。有关更多选项,请参阅 scipy.spatial.distance.pdist 文档。 [https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html) 要对行和列使用不同的度量(或方法),您可以子集构造每个链接矩阵,并将它们提供为`{row, col}_linkage.`
`z_score`:int or None, optional
`z_score`:int 或 None,可选。
> Either 0 (rows) or 1 (columns). Whether or not to calculate z-scores for the rows or the columns. Z scores are: z = (x - mean)/std, so values in each row (column) will get the mean of the row (column) subtracted, then divided by the standard deviation of the row (column). This ensures that each row (column) has mean of 0 and variance of 1.
> 0(行)或 1(列)。是否计算行或列的 z 分数。Z 得分为 z = (x - mean)/std,因此每行(列)中的值将减去行(列)的平均值,然后除以行(列)的标准偏差。这可确保每行(列)的均值为 0,方差为 1.
`standard_scale`:int or None, optional
`standard_scale`:int 或 None, 可选。
> Either 0 (rows) or 1 (columns). Whether or not to standardize that dimension, meaning for each row or column, subtract the minimum and divide each by its maximum.
> 0(行)或 1(列)。是否标准化该维度,即每行或每列的含义,减去最小值并将每个维度除以其最大值。
**figsize: tuple of two ints, optional**
**figsize: 两个整数的元组, 可选。**
> Size of the figure to create.
> 要创建的图形的大小。
`cbar_kws`dict, optional
`cbar_kws`字典, 可选。
> Keyword arguments to pass to `cbar_kws` in `heatmap`, e.g. to add a label to the colorbar.
> 要传递给`heatmap`中的`cbar_kws`的关键字参数,例如向彩条添加标签。
`{row,col}_cluster`bool, optional
`{row,col}_cluster`布尔值, 可选。
> If True, cluster the {rows, columns}.
> 如果为真,则对{rows, columns}进行聚类。
`{row,col}_linkage`:numpy.array, optional
`{row,col}_linkage`:numpy.array, 可选。
> Precomputed linkage matrix for the rows or columns. See scipy.cluster.hierarchy.linkage for specific formats.
> 行或列的预计算链接矩阵。有关特定格式,请参阅 scipy.cluster.hierarchy.linkage.
`{row,col}_colors`:list-like or pandas DataFrame/Series, optional
`{row,col}_colors`:list-like 或 pandas DataFrame/Series, 可选。
> List of colors to label for either the rows or columns. Useful to evaluate whether samples within a group are clustered together. Can use nested lists or DataFrame for multiple color levels of labeling. If given as a DataFrame or Series, labels for the colors are extracted from the DataFrames column names or from the name of the Series. DataFrame/Series colors are also matched to the data by their index, ensuring colors are drawn in the correct order.
> 要为行或列标记的颜色列表。用于评估组内的样本是否聚集在一起。可以使用嵌套列表或 DataFrame 进行多种颜色级别的标注。如果以 DataFrame 或 Series 形式提供,则从 DataFrames 列名称或 Series 的名称中提取颜色标签。DataFrame/Series 颜色也通过索引与数据匹配,确保以正确的顺序绘制颜色。
`mask`boolean array or DataFrame, optional
`mask`布尔数组或 DataFrame, 可选。
> If passed, data will not be shown in cells where `mask` is True. Cells with missing values are automatically masked. Only used for visualizing, not for calculating.
> 如果通过,数据将不会显示在`mask`为真的单元格中。具有缺失值的单元格将自动被屏蔽。仅用于可视化,不用于计算。
`kwargs`other keyword arguments
`kwargs`其他关键字参数。
> All other keyword arguments are passed to `sns.heatmap`
> 所有其他关键字参数都传递给`sns.heatmap`
返回值:`clustergrid`:ClusterGrid
> A ClusterGrid instance.
> ClusterGrid 实例。
Notes
注意点:
The returned object has a `savefig` method that should be used if you want to save the figure object without clipping the dendrograms.
返回的对象有一个`savefig`方法,如果要保存图形对象而不剪切树形图,则应使用该方法。
To access the reordered row indices, use: `clustergrid.dendrogram_row.reordered_ind`
要访问重新排序的行索引,请使用:`clustergrid.dendrogram_row.reordered_in`
Column indices, use: `clustergrid.dendrogram_col.reordered_ind`
列索引, 请使用: `clustergrid.dendrogram_col.reordered_ind`
Examples
范例
Plot a clustered heatmap:
绘制聚类热图。
```py
>>> import seaborn as sns; sns.set(color_codes=True)
......@@ -87,7 +89,7 @@ Plot a clustered heatmap:
![http://seaborn.pydata.org/_images/seaborn-clustermap-1.png](img/a7da372ba56ceec7b8b9e01f418bb1e3.jpg)
Use a different similarity metric:
使用不同的相似性指标。
```py
>>> g = sns.clustermap(iris, metric="correlation")
......@@ -96,7 +98,7 @@ Use a different similarity metric:
![http://seaborn.pydata.org/_images/seaborn-clustermap-2.png](img/e102a295ca812e5085369488cedb3dac.jpg)
Use a different clustering method:
使用不同的聚类方法。
```py
>>> g = sns.clustermap(iris, method="single")
......@@ -105,7 +107,7 @@ Use a different clustering method:
![http://seaborn.pydata.org/_images/seaborn-clustermap-3.png](img/64c061b1d37ef563dc9827fbb5c671a1.jpg)
Use a different colormap and ignore outliers in colormap limits:
使用不同的色彩映射并忽略色彩映射限制中的异常值。
```py
>>> g = sns.clustermap(iris, cmap="mako", robust=True)
......@@ -114,7 +116,7 @@ Use a different colormap and ignore outliers in colormap limits:
![http://seaborn.pydata.org/_images/seaborn-clustermap-4.png](img/b9161032a5adb7fb6694c185246664aa.jpg)
Change the size of the figure:
改变图的大小。
```py
>>> g = sns.clustermap(iris, figsize=(6, 7))
......@@ -123,7 +125,7 @@ Change the size of the figure:
![http://seaborn.pydata.org/_images/seaborn-clustermap-5.png](img/f7ed7c41c4e6dbed729d2a3ea8e2d0ff.jpg)
Plot one of the axes in its original organization:
绘制其原始组织中的一个轴。
```py
>>> g = sns.clustermap(iris, col_cluster=False)
......@@ -132,7 +134,7 @@ Plot one of the axes in its original organization:
![http://seaborn.pydata.org/_images/seaborn-clustermap-6.png](img/3acbff477d462457ef54fe167311c30e.jpg)
Add colored labels:
添加彩色标签。
```py
>>> lut = dict(zip(species.unique(), "rbg"))
......@@ -143,7 +145,7 @@ Add colored labels:
![http://seaborn.pydata.org/_images/seaborn-clustermap-7.png](img/da7ff8019c2f5f473c8c8958fd395e76.jpg)
Standardize the data within the columns:
标准化列中的数据。
```py
>>> g = sns.clustermap(iris, standard_scale=1)
......@@ -152,11 +154,11 @@ Standardize the data within the columns:
![http://seaborn.pydata.org/_images/seaborn-clustermap-8.png](img/4c9cb45bac2fd0bc0e8ebf7b6411ecc9.jpg)
Normalize the data within the rows:
正规化行内数据。
```py
>>> g = sns.clustermap(iris, z_score=0)
```
![http://seaborn.pydata.org/_images/seaborn-clustermap-9.png](img/5e7f4bf9cb93adb18b8275b2e6477182.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-clustermap-9.png](img/5e7f4bf9cb93adb18b8275b2e6477182.jpg)
......@@ -12,21 +12,21 @@ class seaborn.FacetGrid(data, row=None, col=None, hue=None, col_wrap=None, share
__init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=True, height=3, aspect=1, palette=None, row_order=None, col_order=None, hue_order=None, hue_kws=None, dropna=True, legend_out=True, despine=True, margin_titles=False, xlim=None, ylim=None, subplot_kws=None, gridspec_kws=None, size=None)
```
初始化matplotlib画布和FacetGrid对象。
初始化 matplotlib 画布和 FacetGrid 对象。
该类将数据集映射到由行和列组成的网格中的多个轴上,这些轴与数据集中变量的级别对应。它产生的图通常被称为“lattice”,“trellis”或“small-multiple”图形。
它还可以用`hue`参数表示第三个变量的级别,该参数绘制不同颜色的不同数据子集。它使用颜色来解析第三维度上的元素,但是只绘制相互重叠的子集,并且不会像接受“hue”的坐标轴级函数那样为特定的可视化定制“hue”参数。
当使用从数据集推断语义映射的seaborn函数时,必须注意在各个方面之间同步这些映射。在大多数情况下,使用图形级函数(例如[`relplot()`](seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot"))比直接使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")更好。
当使用从数据集推断语义映射的 seaborn 函数时,必须注意在各个方面之间同步这些映射。在大多数情况下,使用图形级函数(例如[`relplot()`](seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot"))比直接使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")更好。
基本工作流程是使用数据集和用于构造网格的变量初始化FacetGrid对象。然后,通过调用[`FacetGrid.map()`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")[`FacetGrid.map_dataframe()`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe"),可以将一个或多个绘图函数应用于每个子集。最后,可以使用其他方法调整绘图,以执行更改轴标签、使用不同刻度或添加图例等操作。有关详细信息,请参阅下面的详细代码示例。
基本工作流程是使用数据集和用于构造网格的变量初始化 FacetGrid 对象。然后,通过调用[`FacetGrid.map()`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")[`FacetGrid.map_dataframe()`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe"),可以将一个或多个绘图函数应用于每个子集。最后,可以使用其他方法调整绘图,以执行更改轴标签、使用不同刻度或添加图例等操作。有关详细信息,请参阅下面的详细代码示例。
更多相关信息请参阅[`教程`](../tutorial/axis_grids.html#grid-tutorial)
更多相关信息请参阅[`教程`](http://seaborn.pydata.org/tutorial/axis_grids.html#grid-tutorial)
参数:`data`:DataFrame数据。
参数:`data`:DataFrame 数据。
> 整洁的(“长形式”)dataframe数据,其中每一列是一个变量,每一行是一个观察实例。
> 整洁的(“长形式”)dataframe 数据,其中每一列是一个变量,每一行是一个观察实例。
`row, col, hue`:字符串。
......@@ -38,7 +38,7 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
`share{x,y}`:布尔值,'col' 或 'row'可选
> 如果为true,则跨列共享y轴或者跨行共享x轴。
> 如果为 true,则跨列共享 y 轴或者跨行共享 x 轴。
`height`:标量,可选参数。
......@@ -46,15 +46,15 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
`aspect`:标量,可选参数。
> 每个图片的纵横比,因此aspect * height给出每个图片的宽度,单位为英寸。
> 每个图片的纵横比,因此 aspect * height 给出每个图片的宽度,单位为英寸。
`palette`:调色板名称,列表或字典,可选参数。
> 用于色调变量的不同级别的颜色。应为[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的参数,或者是将色调级别映射到matplotlib颜色的字典。
> 用于色调变量的不同级别的颜色。应为[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的参数,或者是将色调级别映射到 matplotlib 颜色的字典。
`{row,col,hue}_order`:列表,可选参数。
> 对所给命令级别进行排序。默认情况下,这将是在数据中显示的级别,或者,如果变量是pandas分类,则为类别顺序。
> 对所给命令级别进行排序。默认情况下,这将是在数据中显示的级别,或者,如果变量是 pandas 分类,则为类别顺序。
`hue_kws`:参数-列表值的映射字典
......@@ -62,7 +62,7 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
`legend_out`:布尔值,可选参数。
> 如果为True,则图形尺寸将被扩展,图例将绘制在中间右侧的图形之外。
> 如果为 True,则图形尺寸将被扩展,图例将绘制在中间右侧的图形之外。
`despine`:布尔值,可选参数。
......@@ -70,19 +70,19 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
`margin_titles`:布尔值,可选参数。
> 如果为True,则行变量的标题将绘制在最后一列的右侧。此选项是实验性的,可能无法在所有情况下使用。
> 如果为 True,则行变量的标题将绘制在最后一列的右侧。此选项是实验性的,可能无法在所有情况下使用。
`{x, y}lim`:元组,可选参数。
> 每个图片上每个轴的限制(仅当share {x,y}为True时才相关)。
> 每个图片上每个轴的限制(仅当 share {x,y}为 True 时才相关)。
`subplot_kws`:字典,可选参数。
> 传递给matplotlib subplot(s)方法的关键字参数字典。
> 传递给 matplotlib subplot(s)方法的关键字参数字典。
`gridspec_kws`:字典,可选参数。
> 传递给matplotlib的`gridspec`模块(通过`plt.subplots`)的关键字参数字典。需要matplotlib> = 1.4,如果`col_wrap`不是`None`,则忽略它。
> 传递给 matplotlib 的`gridspec`模块(通过`plt.subplots`)的关键字参数字典。需要 matplotlib> = 1.4,如果`col_wrap`不是`None`,则忽略它。
**另请参见**
......@@ -102,7 +102,7 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
范例
使用tips数据集初始化2x2网格图:
使用 tips 数据集初始化 2x2 网格图:
```py
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
......@@ -124,7 +124,7 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-2.png](img/ee99e47d6e0d2262037bca2e7fdb9772.jpg)
(注意,没有必要重新捕获返回的变量;它是相同的对象,但在示例中这样做使得处理doctests更加方便)。
(注意,没有必要重新捕获返回的变量;它是相同的对象,但在示例中这样做使得处理 doctests 更加方便)。
将其他关键字参数传递给映射函数:
......@@ -316,7 +316,7 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
方法
| [`__init__`](#seaborn.FacetGrid.__init__ "seaborn.FacetGrid.__init__")(data[, row, col, hue, col_wrap, …]) | 初始化matplotlib画布和FacetGrid对象。 |
| [`__init__`](#seaborn.FacetGrid.__init__ "seaborn.FacetGrid.__init__")(data[, row, col, hue, col_wrap, …]) | 初始化 matplotlib 画布和 FacetGrid 对象。 |
| `add_legend`([legend_data, title, label_order]) | 绘制一个图例,可能将其放在轴外并调整图形大小。|
......@@ -328,7 +328,7 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
| [`map`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")(func, *args, \**kwargs) | 将绘图功能应用于每个子图的数据子集。 |
| [`map_dataframe`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe")(func, *args, \**kwargs) | 像`.map`一样,但是将args作为字符串传递并在kwargs中插入数据。 |
| [`map_dataframe`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe")(func, *args, \**kwargs) | 像`.map`一样,但是将 args 作为字符串传递并在 kwargs 中插入数据。 |
| `savefig`(*args, \**kwargs) | 保存图片。 |
......@@ -338,13 +338,13 @@ __init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=
| `set_titles`([template, row_template, …]) | 在每个子图上方或网格边缘绘制标题。 |
| `set_xlabels`([label]) | 在网格的底行标记x轴。 |
| `set_xlabels`([label]) | 在网格的底行标记 x 轴。 |
| `set_xticklabels`([labels, step]) | 在网格的底行设置x轴刻度标签。 |
| `set_xticklabels`([labels, step]) | 在网格的底行设置 x 轴刻度标签。 |
| `set_ylabels`([label]) | 在网格的左列标记y轴。 |
| `set_ylabels`([label]) | 在网格的左列标记 y 轴。 |
| `set_yticklabels`([labels]) | 在网格的左列上设置y轴刻度标签。 |
| `set_yticklabels`([labels]) | 在网格的左列上设置 y 轴刻度标签。 |
属性
......
......@@ -10,11 +10,11 @@ FacetGrid.map(func, *args, **kwargs)
参数:`func`:可调用
> 一个接受数据和关键字参数的绘图函数。它必须绘制到当前活动的matplotlib轴并采用&lt;cite&gt;color&lt;/cite&gt;关键字参数。如果在&lt;cite&gt;hue&lt;/cite&gt;维度上进行分面,必须也使用&lt;cite&gt;label&lt;/cite&gt;关键字参数。
> 一个接受数据和关键字参数的绘图函数。它必须绘制到当前活动的 matplotlib 轴并采用`color`关键字参数。如果在`hue`维度上进行分面,必须也使用`label`关键字参数。
`args`:字符串
> 数据的列名,用于标识要绘制数据的变量。每个变量的数据按照调用中指定变量的顺序传递给&lt;cite&gt;func&lt;/cite&gt;
> 数据的列名,用于标识要绘制数据的变量。每个变量的数据按照调用中指定变量的顺序传递给`func`
`kwargs`:关键字参数
......
......@@ -6,13 +6,13 @@
FacetGrid.map_dataframe(func, *args, **kwargs)
```
`.map`类似,但是将args作为字符串传递并将数据插入到kwargs中.
`.map`类似,但是将 args 作为字符串传递并将数据插入到 kwargs 中.
此方法适用于使用接受长格式DataFrame作为&lt;cite&gt;data&lt;/cite&gt;关键字参数并使用字符串变量名访问该DataFrame中的数据的函数进行绘图。
此方法适用于使用接受长格式 DataFrame 作为`data`关键字参数并使用字符串变量名访问该 DataFrame 中的数据的函数进行绘图。
参数:`func`:可调用
> 一个接受数据和关键字参数的绘图函数。与&lt;cite&gt;map&lt;/cite&gt;方法不同,此处使用的函数必须“理解”Pandas对象。它也必须绘制到当前活动的matpltolib轴并采用&lt;cite&gt;color&lt;/cite&gt;关键字参数。如果在<cite>hue</cite>维度上进行分面,必须也使用<cite>label</cite>关键字参数。
> 一个接受数据和关键字参数的绘图函数。与`map`方法不同,此处使用的函数必须“理解”Pandas 对象。它也必须绘制到当前活动的 matpltolib 轴并采用`color`关键字参数。如果在<cite>hue</cite>维度上进行分面,必须也使用<cite>label</cite>关键字参数。
`args`:字符串
......
# seaborn.PairGrid
> 译者:[sfw134](https://github.com/sfw134)
```py
class seaborn.PairGrid(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None, x_vars=None, y_vars=None, diag_sharey=True, height=2.5, aspect=1, despine=True, dropna=True, size=None)
```
......@@ -10,15 +12,15 @@ class seaborn.PairGrid(data, hue=None, hue_order=None, palette=None, hue_kws=Non
它还可以通过`hue`参数用不同颜色绘制不同的数据子集来表示附加级别的条件化。这使用颜色来解析第三维的元素,但只是在彼此之上绘制子集,并且不会像接受`hue`的轴级函数那样为特定可视化定制`hue`参数。
参考[教程](../tutorial/axis_grids.html#grid-tutorial)获取更多信息。
参考[教程](http://seaborn.pydata.org/tutorial/axis_grids.html#grid-tutorial)获取更多信息。
```py
__init__(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None, x_vars=None, y_vars=None, diag_sharey=True, height=2.5, aspect=1, despine=True, dropna=True, size=None)
```
初始化绘图和PairGrid对象。
初始化绘图和 PairGrid 对象。
参数:`data`:DataFrame格式
参数:`data`:DataFrame 格式
> 整洁(长形式)数据框,其中每列是一个变量,每行是一个观察。
......@@ -30,7 +32,7 @@ __init__(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None,
> 调色板中色调变量的等级顺序
`palette`:字典或者seaborn调色板
`palette`:字典或者 seaborn 调色板
> 用于映射`hue`变量的颜色集.如果是一个字典,键应为`hue`变量中的值。
......@@ -52,7 +54,7 @@ __init__(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None,
`aspect`:标量,可选
> aspect和height的乘积得出每个刻面的宽度(以英寸为单位)。
> aspect 和 height 的乘积得出每个刻面的宽度(以英寸为单位)。
`despine`:布尔值,可选
......@@ -179,7 +181,7 @@ __init__(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None,
方法
| [`__init__`](#seaborn.PairGrid.__init__ "seaborn.PairGrid.__init__")(data[, hue, hue_order, palette, …]) | 初始化绘图和PairGrid对象。 |
| [`__init__`](#seaborn.PairGrid.__init__ "seaborn.PairGrid.__init__")(data[, hue, hue_order, palette, …]) | 初始化绘图和 PairGrid 对象。 |
| `add_legend`([legend_data, title, label_order]) | 绘制一个图例,可能将其放在轴外并调整图形大小。 |
| [`map`](seaborn.PairGrid.map.html#seaborn.PairGrid.map "seaborn.PairGrid.map")(func, **kwargs) | 在每一个子图上用相同的函数绘制。 |
| [`map_diag`](seaborn.PairGrid.map_diag.html#seaborn.PairGrid.map_diag "seaborn.PairGrid.map_diag")(func, **kwargs) | 在每个对角线子图上用一个单变量函数绘制。 |
......
# seaborn.PairGrid.map
> 译者:[sfw134](https://github.com/sfw134)
```py
PairGrid.map(func, **kwargs)
```
......@@ -8,5 +10,5 @@ PairGrid.map(func, **kwargs)
参数:`func`:可调用的绘图函数
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为`color`和`label`的kwargs。
> 必须将 x,y 数组作为位置参数并绘制到“当前活动”的 matplotlib 轴上。还需要接受名为`color`和`label`的 kwargs。
# seaborn.PairGrid.map_diag
> 译者:[sfw134](https://github.com/sfw134)
```py
PairGrid.map_diag(func, **kwargs)
```
......@@ -8,5 +10,5 @@ PairGrid.map_diag(func, **kwargs)
参数:`func`:可调用的绘图函数
>必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
>必须将 x,y 数组作为位置参数并绘制到“当前活动”的 matplotlib 轴上。还需要接受名为 color 和 label 的 kwargs。
# seaborn.PairGrid.map_offdiag
> 译者:[sfw134](https://github.com/sfw134)
```py
PairGrid.map_offdiag(func, **kwargs)
```
......@@ -8,5 +10,5 @@ PairGrid.map_offdiag(func, **kwargs)
参数:`func`:可调用的绘图函数
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
> 必须将 x,y 数组作为位置参数并绘制到“当前活动”的 matplotlib 轴上。还需要接受名为 color 和 label 的 kwargs。
# seaborn.PairGrid.map_lower
> 译者:[sfw134](https://github.com/sfw134)
```py
PairGrid.map_lower(func, **kwargs)
```
......@@ -8,5 +10,5 @@ PairGrid.map_lower(func, **kwargs)
参数:`func`:可调用的绘图函数
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为`color`和`label`的kwargs。
> 必须将 x,y 数组作为位置参数并绘制到“当前活动”的 matplotlib 轴上。还需要接受名为`color`和`label`的 kwargs。
......@@ -4,7 +4,7 @@
[绘制关系图](relational.html#relational-tutorial)的教程中,我们学习了如何使用不同的可视化方法来展示数据集中多个变量之间的关系。在示例中,我们专注于两个数值变量之间的主要关系。如果其中一个主要变量是“可分类的”(能被分为不同的组),那么我们可以使用更专业的可视化方法。
seaborn中,有几种不同的方法可以对分类数据进行可视化。类似于[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")或者[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")之间的关系,有两种方法可以制作这些图。有许多axes-level函数可以用不同的方式绘制分类数据,还有一个figure-level接口[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot"),可以对它们进行统一的高级访问。
seaborn 中,有几种不同的方法可以对分类数据进行可视化。类似于[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`scatterplot()`](../generated/seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot")或者[`lineplot()`](../generated/seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot")之间的关系,有两种方法可以制作这些图。有许多 axes-level 函数可以用不同的方式绘制分类数据,还有一个 figure-level 接口[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot"),可以对它们进行统一的高级访问。
将不同的分类图类型视为三个不同的家族,这是很有帮助的。下面我们将详细讨论,它们是:
......@@ -25,9 +25,9 @@
* [`barplot()`](../generated/seaborn.barplot.html#seaborn.barplot "seaborn.barplot") (with `kind="bar"`)
* [`countplot()`](../generated/seaborn.countplot.html#seaborn.countplot "seaborn.countplot") (with `kind="count"`)
这些家族使用不同的粒度级别来表示数据,我们应该根据实际情况来决定到底要使用哪个。它们有统一的API,所以我们可以轻松地在不同类型之间进行切换,并从多个角度来观察数据。
这些家族使用不同的粒度级别来表示数据,我们应该根据实际情况来决定到底要使用哪个。它们有统一的 API,所以我们可以轻松地在不同类型之间进行切换,并从多个角度来观察数据。
在本教程中,我们主要关注figure-level接口[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")。这个函数是上述每个函数更高级别的接口,因此当我们显示每种绘图时都会引用它们,不清楚的话可以随时查看特定类型的API文档。
在本教程中,我们主要关注 figure-level 接口[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")。这个函数是上述每个函数更高级别的接口,因此当我们显示每种绘图时都会引用它们,不清楚的话可以随时查看特定类型的 API 文档。
```py
import seaborn as sns
......@@ -38,7 +38,7 @@ sns.set(style="ticks", color_codes=True)
## 分类散点图
[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")中,数据默认使用散点图表示。在seaborn中有两种不同的分类散点图,它们采用不同的方法来表示分类数据。 其中一种是属于一个类别的所有点,将沿着与分类变量对应的轴落在相同位置。[`stripplot()`](../generated/seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot")方法是[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")中kind的默认参数,它是用少量随机“抖动”调整分类轴上的点的位置:
[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")中,数据默认使用散点图表示。在 seaborn 中有两种不同的分类散点图,它们采用不同的方法来表示分类数据。 其中一种是属于一个类别的所有点,将沿着与分类变量对应的轴落在相同位置。[`stripplot()`](../generated/seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot")方法是[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")中 kind 的默认参数,它是用少量随机“抖动”调整分类轴上的点的位置:
```py
tips = sns.load_dataset("tips")
......@@ -57,7 +57,7 @@ sns.catplot(x="day", y="total_bill", jitter=False, data=tips);
![http://seaborn.pydata.org/_images/categorical_6_0.png](img/69f7923f9645a5a6bd0152889dc41109.jpg)
另一种方法使用防止它们重叠的算法沿着分类轴调整点。我们可以用它更好地表示观测分布,但是只适用于相对较小的数据集。这种绘图有时被称为“beeswarm”,可以使用seaborn中的[`swarmplot()`](../generated/seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot")绘制,通过在[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")中设置`kind="swarm"`来激活:
另一种方法使用防止它们重叠的算法沿着分类轴调整点。我们可以用它更好地表示观测分布,但是只适用于相对较小的数据集。这种绘图有时被称为“beeswarm”,可以使用 seaborn 中的[`swarmplot()`](../generated/seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot")绘制,通过在[`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")中设置`kind="swarm"`来激活:
```py
sns.catplot(x="day", y="total_bill", kind="swarm", data=tips);
......@@ -75,7 +75,7 @@ sns.catplot(x="day", y="total_bill", hue="sex", kind="swarm", data=tips);
![http://seaborn.pydata.org/_images/categorical_10_0.png](img/5ad59a428adab872b085f94007435de3.jpg)
与数值数据不同,如何沿着轴顺序排列分类变量并不总是显而易见的。通常,seaborn分类绘图函数试图从数据中推断出类别的顺序。 如果您的数据具有pandas中的`Categorical`数据类型,则可以在此处设置类别的默认顺序。如果传递给分类轴的变量看起来是数字,则将对级别进行排序。但是数据仍然被视为分类并在分类轴上的序数位置(特别是0,1,......)处理,即使用数字来标记它们:
与数值数据不同,如何沿着轴顺序排列分类变量并不总是显而易见的。通常,seaborn 分类绘图函数试图从数据中推断出类别的顺序。 如果您的数据具有 pandas 中的`Categorical`数据类型,则可以在此处设置类别的默认顺序。如果传递给分类轴的变量看起来是数字,则将对级别进行排序。但是数据仍然被视为分类并在分类轴上的序数位置(特别是 0,1,......)处理,即使用数字来标记它们:
```py
sns.catplot(x="size", y="total_bill", kind="swarm",
......@@ -108,7 +108,7 @@ sns.catplot(x="total_bill", y="day", hue="time", kind="swarm", data=tips);
### 箱线图
第一个是熟悉的[`boxplot()`](../generated/seaborn.boxplot.html#seaborn.boxplot "seaborn.boxplot")。它可以显示分布的三个四分位数值以及极值。“胡须”延伸到位于下四分位数和上四分位数的1.5 IQR内的点,超出此范围的观察值会独立显示。这意味着箱线图中的每个值对应于数据中的实际观察值。
第一个是熟悉的[`boxplot()`](../generated/seaborn.boxplot.html#seaborn.boxplot "seaborn.boxplot")。它可以显示分布的三个四分位数值以及极值。“胡须”延伸到位于下四分位数和上四分位数的 1.5 IQR 内的点,超出此范围的观察值会独立显示。这意味着箱线图中的每个值对应于数据中的实际观察值。
```py
sns.catplot(x="day", y="total_bill", kind="box", data=tips);
......@@ -125,7 +125,7 @@ sns.catplot(x="day", y="total_bill", hue="smoker", kind="box", data=tips);
![http://seaborn.pydata.org/_images/categorical_20_0.png](img/1f4ad95dbd00806b549ece0b87386cf9.jpg)
此行为被称为“dodging”,默认开启,因为我们假定语义变量嵌套在主分类变量中。如果不是这样,可以禁用dodging:
此行为被称为“dodging”,默认开启,因为我们假定语义变量嵌套在主分类变量中。如果不是这样,可以禁用 dodging:
```py
tips["weekend"] = tips["day"].isin(["Sat", "Sun"])
......@@ -136,7 +136,7 @@ sns.catplot(x="day", y="total_bill", hue="weekend",
![http://seaborn.pydata.org/_images/categorical_22_0.png](img/3690d2883f41b811443d3bfd92e7a9d7.jpg)
一个相关的函数[`boxenplot()`](../generated/seaborn.boxenplot.html#seaborn.boxenplot "seaborn.boxenplot")可以绘制一个与Box-plot类似的图。它为了显示更多信息而对分布的形状进行了优化,比较适合于较大的数据集:
一个相关的函数[`boxenplot()`](../generated/seaborn.boxenplot.html#seaborn.boxenplot "seaborn.boxenplot")可以绘制一个与 Box-plot 类似的图。它为了显示更多信息而对分布的形状进行了优化,比较适合于较大的数据集:
```py
diamonds = sns.load_dataset("diamonds")
......@@ -159,7 +159,7 @@ sns.catplot(x="total_bill", y="day", hue="time",
![http://seaborn.pydata.org/_images/categorical_26_0.png](img/d9dc602fc56dec13039df115c589dd05.jpg)
该方法使用核密度估计来提供更丰富的值分布描述。此外,violin中还显示了来自箱线图的四分位数和whikser值。缺点是由于violinplot使用了KDE,我们需要调整一些额外参数,与箱形图相比增加了一些复杂性:
该方法使用核密度估计来提供更丰富的值分布描述。此外,violin 中还显示了来自箱线图的四分位数和 whikser 值。缺点是由于 violinplot 使用了 KDE,我们需要调整一些额外参数,与箱形图相比增加了一些复杂性:
```py
sns.catplot(x="total_bill", y="day", hue="time",
......@@ -170,7 +170,7 @@ sns.catplot(x="total_bill", y="day", hue="time",
![http://seaborn.pydata.org/_images/categorical_28_0.png](img/93d6927062ff93035052ed79d6e8e224.jpg)
hue参数只有两个级别时,也可以“拆分”violins,这样可以更有效地利用空间:
hue 参数只有两个级别时,也可以“拆分”violins,这样可以更有效地利用空间:
```py
sns.catplot(x="day", y="total_bill", hue="sex",
......@@ -180,7 +180,7 @@ sns.catplot(x="day", y="total_bill", hue="sex",
![http://seaborn.pydata.org/_images/categorical_30_0.png](img/a450fb151022958086f1733274e4f66b.jpg)
最后,在violin内的绘图有几种选项,包括显示每个独立的观察而不是摘要箱线图值的方法:
最后,在 violin 内的绘图有几种选项,包括显示每个独立的观察而不是摘要箱线图值的方法:
```py
sns.catplot(x="day", y="total_bill", hue="sex",
......@@ -191,7 +191,7 @@ sns.catplot(x="day", y="total_bill", hue="sex",
![http://seaborn.pydata.org/_images/categorical_32_0.png](img/a1fee05f41f1d43a9d9a6f1b9c301e0d.jpg)
我们也可以将[`swarmplot()`](../generated/seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot")`striplot()`与箱形图或violin plot结合起来,展示每次观察以及分布摘要:
我们也可以将[`swarmplot()`](../generated/seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot")`striplot()`与箱形图或 violin plot 结合起来,展示每次观察以及分布摘要:
```py
g = sns.catplot(x="day", y="total_bill", kind="violin", inner=None, data=tips)
......@@ -203,11 +203,11 @@ sns.swarmplot(x="day", y="total_bill", color="k", size=3, data=tips, ax=g.ax);
## 类别内的统计估计
对于其他应用程序,你可能希望显示值的集中趋势估计,而不是显示每个类别中的分布。Seaborn有两种主要方式来显示这些信息。重要的是,这些功能的基本API与上面讨论的API相同。
对于其他应用程序,你可能希望显示值的集中趋势估计,而不是显示每个类别中的分布。Seaborn 有两种主要方式来显示这些信息。重要的是,这些功能的基本 API 与上面讨论的 API 相同。
### 条形图
实现这一目标的是我们熟悉的条形图。在seaborn中,[`barplot()`](../generated/seaborn.barplot.html#seaborn.barplot "seaborn.barplot")函数在完整数据集上运行并应用函数来获取估计值(默认情况下取平均值)。当每个类别中有多个观察值时,它还使用自举来计算估计值周围的置信区间,并使用误差条绘制:
实现这一目标的是我们熟悉的条形图。在 seaborn 中,[`barplot()`](../generated/seaborn.barplot.html#seaborn.barplot "seaborn.barplot")函数在完整数据集上运行并应用函数来获取估计值(默认情况下取平均值)。当每个类别中有多个观察值时,它还使用自举来计算估计值周围的置信区间,并使用误差条绘制:
```py
titanic = sns.load_dataset("titanic")
......@@ -217,7 +217,7 @@ sns.catplot(x="sex", y="survived", hue="class", kind="bar", data=titanic);
![http://seaborn.pydata.org/_images/categorical_36_0.png](img/727bcad15c428cfdd74d27db87677157.jpg)
条形图的一个特例是,当你想要显示每个类别中的观察数量而不是计算第二个变量的统计数据时。这类似于分类而非定量变量的直方图。在seaborn中,使用[`countplot()`](../generated/seaborn.countplot.html#seaborn.countplot "seaborn.countplot")函数很容易实现:
条形图的一个特例是,当你想要显示每个类别中的观察数量而不是计算第二个变量的统计数据时。这类似于分类而非定量变量的直方图。在 seaborn 中,使用[`countplot()`](../generated/seaborn.countplot.html#seaborn.countplot "seaborn.countplot")函数很容易实现:
```py
sns.catplot(x="deck", kind="count", palette="ch:.25", data=titanic);
......@@ -248,7 +248,7 @@ sns.catplot(x="sex", y="survived", hue="class", kind="point", data=titanic);
![http://seaborn.pydata.org/_images/categorical_42_0.png](img/687f85f5e0e06a68e6150c0533ff1748.jpg)
当分类函数缺少关系函数中的`style`语义时, 将markers和linestyles与色调一起改变,以制作最大可访问的图形并在黑白中重现良好,这仍然是一个好主意:
当分类函数缺少关系函数中的`style`语义时, 将 markers 和 linestyles 与色调一起改变,以制作最大可访问的图形并在黑白中重现良好,这仍然是一个好主意:
```py
sns.catplot(x="class", y="survived", hue="sex",
......@@ -262,7 +262,7 @@ sns.catplot(x="class", y="survived", hue="sex",
## 绘制“宽格式”数据
虽然优选使用“长形式”或“整齐”数据,但这些函数也可以应用于各种“宽格式”的数据,包括pandas DataFrames或二维numpy数组。这些对象应该直接传递给`data`参数:
虽然优选使用“长形式”或“整齐”数据,但这些函数也可以应用于各种“宽格式”的数据,包括 pandas DataFrames 或二维 numpy 数组。这些对象应该直接传递给`data`参数:
```py
iris = sns.load_dataset("iris")
......@@ -272,7 +272,7 @@ sns.catplot(data=iris, orient="h", kind="box");
![http://seaborn.pydata.org/_images/categorical_46_0.png](img/5307ba94c8d5a2ecca04c697414a762a.jpg)
另外,axes-level函数接受Pandas或numpy对象的向量,而不是`DataFrame`中的变量:
另外,axes-level 函数接受 Pandas 或 numpy 对象的向量,而不是`DataFrame`中的变量:
```py
sns.violinplot(x=iris.species, y=iris.sepal_length);
......@@ -281,7 +281,7 @@ sns.violinplot(x=iris.species, y=iris.sepal_length);
![http://seaborn.pydata.org/_images/categorical_48_0.png](img/426ace59c775cc095c6128e35bcff1b3.jpg)
要控制上面讨论的函数绘制的图形的大小和形状,你必须使用matplotlib命令来进行设置:
要控制上面讨论的函数绘制的图形的大小和形状,你必须使用 matplotlib 命令来进行设置:
```py
f, ax = plt.subplots(figsize=(7, 3))
......@@ -293,7 +293,7 @@ sns.countplot(y="deck", data=titanic, color="c");
当你需要一个分类图与一个更复杂的其他类型的图共存时,你可以采取这种方法。
## 显示与facet的多种关系
## 显示与 facet 的多种关系
就像[`relplot()`](../generated/seaborn.relplot.html#seaborn.relplot "seaborn.relplot")一样, [`catplot()`](../generated/seaborn.catplot.html#seaborn.catplot "seaborn.catplot")建立在[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")上,这意味着很容易添加层面变量来可视化高维关系:
......
# seaborn.PairGrid.map_upper
> 译者:[sfw134](https://github.com/sfw134)
```py
PairGrid.map_upper(func, **kwargs)
```
......@@ -8,5 +10,5 @@ PairGrid.map_upper(func, **kwargs)
参数:`func`:可调用的绘图函数
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
> 必须将 x,y 数组作为位置参数并绘制到“当前活动”的 matplotlib 轴上。还需要接受名为 color 和 label 的 kwargs。
# seaborn.JointGrid
> 译者:[Yet-sun](https://github.com/Yet-sun)
```py
class seaborn.JointGrid(x, y, data=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, size=None)
```
......@@ -18,7 +20,7 @@ __init__(x, y, data=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None,
`data`:DataFrame, 可选
> 当 `x` and `y` 是变量名的时候为DataFrame。
> 当 `x` and `y` 是变量名的时候为 DataFrame。
`height`:数字
......@@ -34,7 +36,7 @@ __init__(x, y, data=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None,
`dropna`:bool, 可选
> 如果为True,则删除 &lt;cite&gt;x&lt;/cite&gt; 和 &lt;cite&gt;y&lt;/cite&gt;中缺少的观察结果。
> 如果为 True,则删除 `x` 和 `y`中缺少的观察结果。
`{x, y}lim`:二元组,可选
......@@ -167,9 +169,9 @@ __init__(x, y, data=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None,
[`plot`](seaborn.JointGrid.plot.html#seaborn.JointGrid.plot "seaborn.JointGrid.plot")(joint_func, marginal_func[, annot_func]) | 绘制完整绘图的快捷方式。
[`plot_joint`](seaborn.JointGrid.plot_joint.html#seaborn.JointGrid.plot_joint "seaborn.JointGrid.plot_joint")(func, **kwargs) | 绘制 &lt;cite&gt;x&lt;/cite&gt;&lt;cite&gt;y&lt;/cite&gt;的双变量图。
[`plot_joint`](seaborn.JointGrid.plot_joint.html#seaborn.JointGrid.plot_joint "seaborn.JointGrid.plot_joint")(func, **kwargs) | 绘制 `x``y`的双变量图。
[`plot_marginals`](seaborn.JointGrid.plot_marginals.html#seaborn.JointGrid.plot_marginals "seaborn.JointGrid.plot_marginals")(func, **kwargs) | 分别绘制 &lt;cite&gt;x&lt;/cite&gt;&lt;cite&gt;y&lt;/cite&gt; 的单变量图。
[`plot_marginals`](seaborn.JointGrid.plot_marginals.html#seaborn.JointGrid.plot_marginals "seaborn.JointGrid.plot_marginals")(func, **kwargs) | 分别绘制 `x``y` 的单变量图。
`savefig`(*args, **kwargs) | 封装 figure.savefig 默认为紧边界框。
......
# seaborn.JointGrid.plot
> 译者:[Yet-sun](https://github.com/Yet-sun)
```py
JointGrid.plot(joint_func, marginal_func, annot_func=None)
```
绘制完整绘图的快捷方式。
直接使用 &lt;cite&gt;plot_joint&lt;/cite&gt;&lt;cite&gt;plot_marginals&lt;/cite&gt; 进行更多控制.
直接使用 `plot_joint``plot_marginals` 进行更多控制.
参数:**joint_func, marginal_func:可调用**
......@@ -14,4 +16,4 @@ JointGrid.plot(joint_func, marginal_func, annot_func=None)
返回值:`self`:JointGrid 实例
> 返回 &lt;cite&gt;self&lt;/cite&gt;.
> 返回 `self`.
# seaborn.JointGrid.plot_joint
> 译者:[Yet-sun](https://github.com/Yet-sun)
```py
JointGrid.plot_joint(func, **kwargs)
```
绘制 &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt;的双变量图。
绘制 `x` and `y`的双变量图。
参数:`func`:可调用的绘图函数
......@@ -16,4 +18,4 @@ JointGrid.plot_joint(func, **kwargs)
返回值:`self`:JointGrid 实例
> 返回 &lt;cite&gt;self&lt;/cite&gt;.
> 返回 `self`.
# seaborn.JointGrid.plot_marginals
> 译者:[Yet-sun](https://github.com/Yet-sun)
```py
JointGrid.plot_marginals(func, **kwargs)
```
分别绘制 &lt;cite&gt;x&lt;/cite&gt;&lt;cite&gt;y&lt;/cite&gt; 的单变量图。
分别绘制 `x``y` 的单变量图。
参数:`func`:可调用的绘图函数
......@@ -16,4 +18,4 @@ JointGrid.plot_marginals(func, **kwargs)
返回值:`self`:JointGrid 实例
> 返回 &lt;cite&gt;self&lt;/cite&gt;.
> 返回 `self`.
# seaborn.set
> 译者:[lbllol365](https://github.com/lbllol365)
```python
seaborn.set(context='notebook', style='darkgrid', palette='deep', font='sans-serif', font_scale=1, color_codes=True, rc=None)
```
......@@ -22,7 +24,7 @@ palette:字符串或者序列
font:字符串
> 字体,参见matplotlib字体管理
> 字体,参见 matplotlib 字体管理
font_scale:浮点数,可选的
......@@ -30,8 +32,8 @@ font_scale:浮点数,可选的
color_codes:布尔值
> 如果为真并且调色板是一个seaborn调色板,重新映射速记颜色代码(比如,"b","g","r",等等)到调色板上的颜色。
> 如果为真并且调色板是一个 seaborn 调色板,重新映射速记颜色代码(比如,"b","g","r",等等)到调色板上的颜色。
rc:字典或者None
rc:字典或者 None
> rc参数字典映射以覆盖以上参数。
\ No newline at end of file
> rc 参数字典映射以覆盖以上参数。
\ No newline at end of file
# seaborn.axes_style
> 译者:[lbllol365](https://github.com/lbllol365)
```python
seaborn.axes_style(style=None,rc=None)
```
......@@ -8,7 +10,7 @@ seaborn.axes_style(style=None,rc=None)
它会影响诸如坐标轴的颜色,是否默认启用网格,和其他自定义元素。
这个函数返回一个对象,该对象可以在with语句中使用以临时改变样式参数。
这个函数返回一个对象,该对象可以在 with 语句中使用以临时改变样式参数。
参数:style:字典,None,或者{darkgrid, whitegrid, dark, white, ticks}其中一个。
......@@ -16,11 +18,11 @@ seaborn.axes_style(style=None,rc=None)
rc:字典,可选的
> 给定参数映射以覆盖预先设定的(默认的)seaborn样式参数字典
> 给定参数映射以覆盖预先设定的(默认的)seaborn 样式参数字典
参见
给一个seaborn主题设定matplotlib参数,返回一个参数字典,以缩放图标元素并可以定义图表的调色板。
给一个 seaborn 主题设定 matplotlib 参数,返回一个参数字典,以缩放图标元素并可以定义图表的调色板。
例子:
......
# seaborn.set_style
> 译者:[lbllol365](https://github.com/lbllol365)
```python
seaborn.set_style(style=None, rc=None)
```
......@@ -14,11 +16,11 @@ seaborn.set_style(style=None, rc=None)
rc:字典,可选
> 一个字典映射去覆盖seaborn样式字典中的预设值。这仅仅会更新那些被认为是样式定义一部分的参数。
> 一个字典映射去覆盖 seaborn 样式字典中的预设值。这仅仅会更新那些被认为是样式定义一部分的参数。
参见
返回一个参数字典或者使用with语句以临时设置style.set 的参数来缩放图表的元素或者设定图表的默认调色板。
返回一个参数字典或者使用 with 语句以临时设置 style.set 的参数来缩放图表的元素或者设定图表的默认调色板。
例子:
......
# seaborn.plotting_context
> 译者:[cancan233](https://github.com/cancan233)
```python
seaborn.plotting_context(context=None, font_scale=1, rc=None)
```
dict形式返回参数,用以缩放图形的元素。
dict 形式返回参数,用以缩放图形的元素。
这些参数可以影响诸如标签大小,线条和绘图的其他元素,但不会影响整体样式。基础文本时"notebook",和其他文本"paper","talk"和"poster",它们分别是0.8,1.3和1.6的notebook参数版本。
这些参数可以影响诸如标签大小,线条和绘图的其他元素,但不会影响整体样式。基础文本时"notebook",和其他文本"paper","talk"和"poster",它们分别是 0.8,1.3 和 1.6 的 notebook 参数版本。
该函数返回一个对象,该对象可以在`with`语句中使用,临时改变文本参数。
......@@ -18,11 +21,11 @@ seaborn.plotting_context(context=None, font_scale=1, rc=None)
`rc`:dict,可选
> 参数映射以覆盖预设的seaborn的文本字典中的值。这只更新被视为文本定义的一部分的参数。
> 参数映射以覆盖预设的 seaborn 的文本字典中的值。这只更新被视为文本定义的一部分的参数。
也可参见
设置matplotlib参数以调整绘图元素返回定义图形样式的参数的dict,定义绘图的调色板。
设置 matplotlib 参数以调整绘图元素返回定义图形样式的参数的 dict,定义绘图的调色板。
示例:
......
# seaborn.set_context
> 译者:[cancan233](https://github.com/cancan233)
```python
seaborn.set_context(context=None, font_scale=1, rc=None)
```
设置绘图文本参数。
这些参数可以影响诸如标签大小,线条和绘图的其他元素,但不会影响整体样式。基础文本时"notebook",和其他文本"paper","talk"和"poster",它们分别是0.8,1.3和1.6的notebook参数版本。
这些参数可以影响诸如标签大小,线条和绘图的其他元素,但不会影响整体样式。基础文本时"notebook",和其他文本"paper","talk"和"poster",它们分别是 0.8,1.3 和 1.6 的 notebook 参数版本。
参数:`context`:dict, None 或者是{paper, notebook, talk, poster}其中一个
......@@ -18,11 +20,11 @@ seaborn.set_context(context=None, font_scale=1, rc=None)
`rc`:dict,可选
> 参数映射以覆盖预设的seaborn的上下文字典中的值。这只更新被视为上下文定义的一部分的参数。
> 参数映射以覆盖预设的 seaborn 的上下文字典中的值。这只更新被视为上下文定义的一部分的参数。
也可参见
返回一个rc参数的字典,或者在`with`语句中使用临时设置context.set图样式的默认为数字的默认调色板
返回一个 rc 参数的字典,或者在`with`语句中使用临时设置 context.set 图样式的默认为数字的默认调色板
示例
......
......@@ -2,7 +2,7 @@
> 译者:[alohahahaha](https://github.com/alohahahaha)
在处理一组数据时,您通常想做的第一件事就是了解变量的分布情况。本教程的这一章将简要介绍seaborn中用于检查单变量和双变量分布的一些工具。 您可能还需要查看[categorical.html](categorical.html #categical-tutorial)章节中的函数示例,这些函数可以轻松地比较变量在其他变量级别上的分布。
在处理一组数据时,您通常想做的第一件事就是了解变量的分布情况。本教程的这一章将简要介绍 seaborn 中用于检查单变量和双变量分布的一些工具。 您可能还需要查看[categorical.html](categorical.html #categical-tutorial)章节中的函数示例,这些函数可以轻松地比较变量在其他变量级别上的分布。
```py
import seaborn as sns
import matplotlib.pyplot as plt
......@@ -13,7 +13,7 @@ sns.set(color_codes=True)
## 绘制单变量分布
seaborn中想要快速查看单变量分布的最方便的方法是使用[`distplot()`](../generated/seaborn.distplot.html#seaborn.distplot "seaborn.distplot")函数。默认情况下,该方法将会绘制直方图[histogram](https://en.wikipedia.org/wiki/Histogram)并拟合[内核密度估计] [kernel density estimate](https://en.wikipedia.org/wiki/Kernel_density_estimation) (KDE).
seaborn 中想要快速查看单变量分布的最方便的方法是使用[`distplot()`](../generated/seaborn.distplot.html#seaborn.distplot "seaborn.distplot")函数。默认情况下,该方法将会绘制直方图[histogram](https://en.wikipedia.org/wiki/Histogram)并拟合[内核密度估计] [kernel density estimate](https://en.wikipedia.org/wiki/Kernel_density_estimation) (KDE).
```py
x = np.random.normal(size=100)
......@@ -25,8 +25,8 @@ sns.distplot(x);
### 直方图
对于直方图我们可能很熟悉,而且matplotlib中已经存在`hist`函数。 直方图首先确定数据区间,然后观察数据落入这些区间中的数量来绘制柱形图以此来表征数据的分布情况。
为了说明这一点,让我们删除密度曲线并添加一个rug plot,它在每个观察值上画一个小的垂直刻度。您可以使用[`rugplot()`](../generated/seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot") 函数来创建rugplot本身,但是也可以在 [`distplot()`](../generated/seaborn.distplot.html#seaborn.distplot "seaborn.distplot")中使用:
对于直方图我们可能很熟悉,而且 matplotlib 中已经存在`hist`函数。 直方图首先确定数据区间,然后观察数据落入这些区间中的数量来绘制柱形图以此来表征数据的分布情况。
为了说明这一点,让我们删除密度曲线并添加一个 rug plot,它在每个观察值上画一个小的垂直刻度。您可以使用[`rugplot()`](../generated/seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot") 函数来创建 rugplot 本身,但是也可以在 [`distplot()`](../generated/seaborn.distplot.html#seaborn.distplot "seaborn.distplot")中使用:
```py
sns.distplot(x, kde=False, rug=True);
......@@ -46,7 +46,7 @@ sns.distplot(x, bins=20, kde=False, rug=True);
### 核密度估计
可能你对核密度估计不太熟悉,但它可以是绘制分布形状的有力工具。和直方图一样,KDE图沿另一个轴的高度,编码一个轴上的观测密度:
可能你对核密度估计不太熟悉,但它可以是绘制分布形状的有力工具。和直方图一样,KDE 图沿另一个轴的高度,编码一个轴上的观测密度:
```py
sns.distplot(x, hist=False, rug=True);
......@@ -54,7 +54,7 @@ sns.distplot(x, hist=False, rug=True);
![http://seaborn.pydata.org/_images/distributions_12_0.png](img/a6d422236da60cc9bd01d12080b60453.jpg)
绘制KDE比绘制直方图更需要计算。每个观测值首先被一个以该值为中心的正态(高斯)曲线所取代:
绘制 KDE 比绘制直方图更需要计算。每个观测值首先被一个以该值为中心的正态(高斯)曲线所取代:
```py
x = np.random.normal(0, 1, size=30)
bandwidth = 1.06 * x.std() * x.size ** (-1 / 5.)
......@@ -73,7 +73,7 @@ sns.rugplot(x, color=".2", linewidth=3);
![http://seaborn.pydata.org/_images/distributions_14_0.png](img/31ee2d7a3dfda467565a2053ac19a38f.jpg)
接下来,对这些曲线求和,计算支持网格(support grid)中每个点的密度值。然后对得到的曲线进行归一化,使曲线下的面积等于1:
接下来,对这些曲线求和,计算支持网格(support grid)中每个点的密度值。然后对得到的曲线进行归一化,使曲线下的面积等于 1:
```py
from scipy.integrate import trapz
......@@ -85,7 +85,7 @@ plt.plot(support, density);
![http://seaborn.pydata.org/_images/distributions_16_0.png](img/d0ff3115fb5935fe56c1bb8123d5ddce.jpg)
我们可以看到,如果在seaborn中使用[`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot") 函数, 我们可以得到相同的曲线。这个函数也被[`distplot()`](../generated/seaborn.distplot.html#seaborn.distplot "seaborn.distplot")所使用, 但是当您只想要密度估计时,它提供了一个更直接的接口,可以更容易地访问其他选项:
我们可以看到,如果在 seaborn 中使用[`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot") 函数, 我们可以得到相同的曲线。这个函数也被[`distplot()`](../generated/seaborn.distplot.html#seaborn.distplot "seaborn.distplot")所使用, 但是当您只想要密度估计时,它提供了一个更直接的接口,可以更容易地访问其他选项:
```py
sns.kdeplot(x, shade=True);
......@@ -94,7 +94,7 @@ sns.kdeplot(x, shade=True);
![http://seaborn.pydata.org/_images/distributions_18_0.png](img/247df80468d3edbc28836cb1cc56c81c.jpg)
KDE的带宽(`bw`)参数控制估计与数据的拟合程度,就像直方图中的bin大小一样。 它对应于我们在上面绘制的内核的宽度。 默认行为尝试使用常用参考规则猜测一个好的值,但尝试更大或更小的值可能会有所帮助:
KDE 的带宽(`bw`)参数控制估计与数据的拟合程度,就像直方图中的 bin 大小一样。 它对应于我们在上面绘制的内核的宽度。 默认行为尝试使用常用参考规则猜测一个好的值,但尝试更大或更小的值可能会有所帮助:
```py
sns.kdeplot(x)
sns.kdeplot(x, bw=.2, label="bw: 0.2")
......@@ -105,7 +105,7 @@ plt.legend();
![http://seaborn.pydata.org/_images/distributions_20_0.png](img/8a713fe4da039acf9c3a4e70b274b60a.jpg)
正如您在上面所看到的,高斯KDE过程的本质意味着估计超出了数据集中最大和最小的值。有可能控制超过极值多远的曲线是由'cut'参数绘制的;然而,这只影响曲线的绘制方式,而不影响曲线的拟合方式:
正如您在上面所看到的,高斯 KDE 过程的本质意味着估计超出了数据集中最大和最小的值。有可能控制超过极值多远的曲线是由'cut'参数绘制的;然而,这只影响曲线的绘制方式,而不影响曲线的拟合方式:
```py
sns.kdeplot(x, shade=True, cut=0)
......@@ -130,7 +130,7 @@ sns.distplot(x, kde=False, fit=stats.gamma);
## 绘制二元分布
它对于可视化两个变量的二元分布也很有用。在seaborn中,最简单的方法就是使用[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")函数,它创建了一个多面板图形,显示了两个变量之间的二元(或联合)关系,以及每个变量在单独轴上的一元(或边际)分布。
它对于可视化两个变量的二元分布也很有用。在 seaborn 中,最简单的方法就是使用[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")函数,它创建了一个多面板图形,显示了两个变量之间的二元(或联合)关系,以及每个变量在单独轴上的一元(或边际)分布。
```py
mean, cov = [0, 1], [(1, .5), (.5, 1)]
......@@ -141,7 +141,7 @@ df = pd.DataFrame(data, columns=["x", "y"])
### 散点图
可视化二元分布最常见的方法是散点图,其中每个观察点都以_x_和_y_值表示。 这类似于二维rug plot。 您可以使用matplotlib`plt.scatter` 函数绘制散点图, 它也是 [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")函数显示的默认类型的图:
可视化二元分布最常见的方法是散点图,其中每个观察点都以 _x_ 和 _y_ 值表示。 这类似于二维 rug plot。 您可以使用 matplotlib `plt.scatter` 函数绘制散点图, 它也是 [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")函数显示的默认类型的图:
```py
sns.jointplot(x="x", y="y", data=df);
......@@ -152,7 +152,7 @@ sns.jointplot(x="x", y="y", data=df);
### 六边形“桶”(Hexbin)图
类似于单变量的直方图,用于描绘二元变量关系的图称为 “hexbin” 图,因为它显示了落入六边形“桶”内的观察计数。 此图对于相对较大的数据集最有效。它可以通过调用matplotlib中的 `plt.hexbin`函数获得并且在[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")作为一种样式。当使用白色作为背景色时效果最佳。
类似于单变量的直方图,用于描绘二元变量关系的图称为 “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,7 +165,7 @@ with sns.axes_style("white"):
### 核密度估计
也可以使用上面描述的核密度估计过程来可视化二元分布。在seaborn中,这种图用等高线图表示, 在[`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");
......@@ -174,7 +174,7 @@ sns.jointplot(x="x", y="y", data=df, kind="kde");
![http://seaborn.pydata.org/_images/distributions_32_0.png](img/3fa9b8716f00e81aa6ca6864cb110e2b.jpg)
您还可以使用[`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")函数绘制二维核密度图。这允许您在一个特定的(可能已经存在的)matplotlib轴上绘制这种图,而 [`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") 函数能够管理它自己的图:
您还可以使用[`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))
......@@ -211,7 +211,7 @@ g.set_axis_labels("$X$", "$Y$");
## 可视化数据集中的成对关系
要在数据集中绘制多个成对的双变量分布,您可以使用[`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot")函数。 这将创建一个轴矩阵并显示DataFrame中每对列的关系,默认情况下,它还绘制对角轴上每个变量的单变量分布:
要在数据集中绘制多个成对的双变量分布,您可以使用[`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot")函数。 这将创建一个轴矩阵并显示 DataFrame 中每对列的关系,默认情况下,它还绘制对角轴上每个变量的单变量分布:
```py
iris = sns.load_dataset("iris")
sns.pairplot(iris);
......
# seaborn.set_color_codes
> 译者:[cancan233](https://github.com/cancan233)
```python
seaborn.set_color_codes(palette='deep')
```
改变matplotlib颜色缩写词的解释方式。
改变 matplotlib 颜色缩写词的解释方式。
调用此方法将改变matplotlib在后续图表中解释缩写词,例如"b"或"g"的方式。
调用此方法将改变 matplotlib 在后续图表中解释缩写词,例如"b"或"g"的方式。
参数: `palette`: {deep, muted, pastel, dark, bright, colorblind}
> 预命名的seaborn调色板,用作颜色的来源
> 预命名的 seaborn 调色板,用作颜色的来源
参见
可以通过高级seaborn样式管理器设置颜色代码。也可以通过设置matplotlib颜色循环功能设置颜色代码。
可以通过高级 seaborn 样式管理器设置颜色代码。也可以通过设置 matplotlib 颜色循环功能设置颜色代码。
示例:
matplotlib颜色代码映射到默认的seaborn调色板。
matplotlib 颜色代码映射到默认的 seaborn 调色板。
```python
>>> import matplotlib.pyplot as plt
......@@ -29,7 +31,7 @@ seaborn.set_color_codes(palette='deep')
![http://seaborn.pydata.org/_images/seaborn-set_color_codes-1.png](img/f7331a33eaedf9eae59191642f7a64e4.jpg)
使用不同的seaborn调色板
使用不同的 seaborn 调色板
```python
>>> sns.set_color_codes("dark")
......
# seaborn.reset_defaults
> 译者:[cancan233](https://github.com/cancan233)
```python
seaborn.reset_defaults()
```
重置所有RC设置至默认设置。
\ No newline at end of file
重置所有 RC 设置至默认设置。
\ No newline at end of file
# seaborn.reset_orig
> 译者:[cancan233](https://github.com/cancan233)
```python
seaborn.reset_orig()
```
将所有RC参数恢复为最初设置(相对于自定义rc而言)。
将所有 RC 参数恢复为最初设置(相对于自定义 rc 而言)。
......@@ -6,7 +6,7 @@
seaborn.set_palette(palette, n_colors=None, desat=None, color_codes=False)
```
通过searborn调色板设置matplotlib色彩循环
通过 searborn 调色板设置 matplotlib 色彩循环
参数:`palette`:seaborn color paltte &#124; matplotlib colormap &#124; hls &#124; husl
......@@ -22,7 +22,7 @@ seaborn.set_palette(palette, n_colors=None, desat=None, color_codes=False)
`color_codes`:bool
> 如果为`True`,并且`palette`是seaborn调色板, 则将颜色代码简写 (例如“b”, “g”, “r”等等)映射到当前调色板上。
> 如果为`True`,并且`palette`是 seaborn 调色板, 则将颜色代码简写 (例如“b”, “g”, “r”等等)映射到当前调色板上。
......
......@@ -26,7 +26,7 @@ matplotlib 调色板的顺序可以通过在调色板名称后添加 “_r”
可以在 `with` 语句中使用此函数来为一个或多个点临时改变调色板。
参考这篇 [教程](../tutorial/color_palettes.html#palette-tutorial) 来获取更多信息。
参考这篇 [教程](http://seaborn.pydata.org/tutorial/color_palettes.html#palette-tutorial) 来获取更多信息。
参数:**palette:None, string, or sequence, optional**
......@@ -50,7 +50,7 @@ matplotlib 调色板的顺序可以通过在调色板名称后添加 “_r”
另外
设置所有的默认颜色循环。重新分配颜色代码,如 “b”、“g” 等。从seaborn 调色板中选择颜色。
设置所有的默认颜色循环。重新分配颜色代码,如 “b”、“g” 等。从 seaborn 调色板中选择颜色。
例子
......@@ -64,7 +64,7 @@ matplotlib 调色板的顺序可以通过在调色板名称后添加 “_r”
![http://seaborn.pydata.org/_images/seaborn-color_palette-1.png](img/9a5bb2b7fbd94af1db1d911dfbec1f7c.jpg)
显示另一个 “seaborn 调色板”,具有与默认 matplotlib 颜色循环相同的基本色调顺序,但颜色更吸引人。默认情况下,使用调色板名称进行调用将返回6种颜色:
显示另一个 “seaborn 调色板”,具有与默认 matplotlib 颜色循环相同的基本色调顺序,但颜色更吸引人。默认情况下,使用调色板名称进行调用将返回 6 种颜色:
```py
>>> sns.palplot(sns.color_palette("muted"))
......
......@@ -8,7 +8,7 @@ seaborn.cubehelix_palette(n_colors=6, start=0, rot=0.4, gamma=1.0, hue=0.8, ligh
用 cubehelix 系统制作顺序调色板。
生成亮度呈线性减小(或增大)的 colormap。这意味着 colormap在转换为黑白模式时(用于打印)的信息将得到保留,且对色盲友好。“cubehelix” 也可以作为基于 matplotlib 的调色板使用,但此函数使用户可以更好地控制调色板的外观,并且具有一组不同的默认值。
生成亮度呈线性减小(或增大)的 colormap。这意味着 colormap 在转换为黑白模式时(用于打印)的信息将得到保留,且对色盲友好。“cubehelix” 也可以作为基于 matplotlib 的调色板使用,但此函数使用户可以更好地控制调色板的外观,并且具有一组不同的默认值。
除了使用这个函数,还可以在 seaborn 中使用字符串速记生成 cubehelix 调色板。 请参见下面的示例。
......
# 线性关系可视化
> 译者:[cancan233](https://github.com/cancan233)
许多数据集包含多定量变量,并且分析的目的通常是将这些变量联系起来。我们[之前讨论](#/docs/5)可以通过显示两个变量相关性的来实现此目的的函数。但是,使用统计模型来估计两组噪声观察量之间的简单关系可能会非常有效。本章讨论的函数将通过线性回归的通用框架实现。
本着图凯(Tukey)精神,seaborn中的回归图主要用于添加视觉指南,以助于在探索性数据分析中强调存在于数据集的模式。换而言之,seaborn本身不是为统计分析而生。要获得与回归模型拟合相关定量度量,你应当使用 [statsmodels](https://www.statsmodels.org/). 然而,seaborn的目标是通过可视化快速简便地3探索数据集,因为这样做,如果说不上更,是与通过统计表探索数据集一样重要。
本着图凯(Tukey)精神,seaborn 中的回归图主要用于添加视觉指南,以助于在探索性数据分析中强调存在于数据集的模式。换而言之,seaborn 本身不是为统计分析而生。要获得与回归模型拟合相关定量度量,你应当使用 [statsmodels](https://www.statsmodels.org/). 然而,seaborn 的目标是通过可视化快速简便地 3 探索数据集,因为这样做,如果说不上更,是与通过统计表探索数据集一样重要。
``` python
import numpy as np
......@@ -20,9 +22,9 @@ tips = sns.load_dataset("tips")
## 绘制线性回归模型的函数
seaborn中两个主要函数主要用于显示回归确定的线性关系。这些函数,[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot"seaborn.regplot")[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot"seaborn.lmplot"), 之间密切关联,并且共享核心功能。但是,了解它们的不同之处非常重要,这样你就可以快速为特定工作选择正确的工具。
seaborn 中两个主要函数主要用于显示回归确定的线性关系。这些函数,[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot"seaborn.regplot")[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot"seaborn.lmplot"), 之间密切关联,并且共享核心功能。但是,了解它们的不同之处非常重要,这样你就可以快速为特定工作选择正确的工具。
在最简单的调用中,两个函数都绘制了两个变量,`x``y`,然后拟合回归模型`y~x`并绘制得到回归线和该回归的95%置信区间:
在最简单的调用中,两个函数都绘制了两个变量,`x``y`,然后拟合回归模型`y~x`并绘制得到回归线和该回归的 95%置信区间:
```python
sns.regplot(x="total_bill", y="tip", data=tips);
......@@ -36,7 +38,7 @@ sns.lmplot(x="total_bill", y="tip", data=tips);
![http://seaborn.pydata.org/_images/regression_8_0.png](img/ff165b205839381bf1fa11c2df3d176d.jpg)
你应当注意到,除了图形形状不同,两幅结果图是完全一致的。我们会在后面解释原因。目前,要了解的另一个主要区别是[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot"seaborn.regplot")接受多种格式的`x``y`变量,包括简单的numpy数组,pandas `Series`对象,或者作为对传递给`data`pandas `DataFrame`对象。相反,[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot"seaborn.lmplot")`data`作为必须参数,`x``y`变量必须被指定为字符串。这种数据格式被称为"长格式"或["整齐"](https://vita.had.co.nz/papers/tidy-data.pdf)数据。 除了这种输入的灵活性之外,[`regplot()`](../ generated / seaborn.regplot.html#seaborn.regplot"seaborn.regplot")拥有[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot"seaborn.lmplot")一个子集的功能,所以我们将使用后者来演示它们。
你应当注意到,除了图形形状不同,两幅结果图是完全一致的。我们会在后面解释原因。目前,要了解的另一个主要区别是[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot"seaborn.regplot")接受多种格式的`x``y`变量,包括简单的 numpy 数组,pandas `Series`对象,或者作为对传递给`data`pandas `DataFrame`对象。相反,[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot"seaborn.lmplot")`data`作为必须参数,`x``y`变量必须被指定为字符串。这种数据格式被称为"长格式"或["整齐"](https://vita.had.co.nz/papers/tidy-data.pdf)数据。 除了这种输入的灵活性之外,[`regplot()`](../ generated / seaborn.regplot.html#seaborn.regplot"seaborn.regplot")拥有[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot"seaborn.lmplot")一个子集的功能,所以我们将使用后者来演示它们。
当其中一个变量采用离散值时,可以拟合线性回归。但是,这种数据集生成的简单散点图通常不是最优的:
......@@ -64,7 +66,7 @@ sns.lmplot(x="size", y="tip", data=tips, x_estimator=np.mean);
## 拟合不同模型
上面使用的简单线性回归模型非常容易拟合,但是它不适合某些类型的数据集。[Anscombe的四重奏](https://en.wikipedia.org/wiki/Anscombe%27s_quartet)数据集展示了一些实例,其中简单线性回归提供了相同的关系估计,然而简单的视觉检查清楚地显示了差异。例如,在第一种情况下,线性回归是一个很好的模型:
上面使用的简单线性回归模型非常容易拟合,但是它不适合某些类型的数据集。[Anscombe 的四重奏](https://en.wikipedia.org/wiki/Anscombe%27s_quartet)数据集展示了一些实例,其中简单线性回归提供了相同的关系估计,然而简单的视觉检查清楚地显示了差异。例如,在第一种情况下,线性回归是一个很好的模型:
```python
anscombe = sns.load_dataset("anscombe")
......@@ -199,7 +201,7 @@ sns.lmplot(x="total_bill", y="tip", hue="smoker",
## 控制绘图的大小和形状
在之前,我们注意到[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot "seaborn.lmplot")生成的默认图看起来相同,但却具有不同的大小和形状。这是因为[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")是一个"轴级"函数,它绘制在特定的轴上。这意味着你可以自己制作多面板图形并精确控制回归图的位置。如果没有明确提供轴对象,它只使用"当前活动"轴,这就是默认绘图与大多数其他matplotlib函数具有相同大小和形状的原因。要控制大小,你需要自己创建一个图形对象。
在之前,我们注意到[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")[`lmplot()`](../generated/seaborn.lmplot.html#seaborn.lmplot "seaborn.lmplot")生成的默认图看起来相同,但却具有不同的大小和形状。这是因为[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")是一个"轴级"函数,它绘制在特定的轴上。这意味着你可以自己制作多面板图形并精确控制回归图的位置。如果没有明确提供轴对象,它只使用"当前活动"轴,这就是默认绘图与大多数其他 matplotlib 函数具有相同大小和形状的原因。要控制大小,你需要自己创建一个图形对象。
```python
f, ax = plt.subplots(figsize=(5, 6))
......@@ -226,7 +228,7 @@ sns.lmplot(x="total_bill", y="tip", col="day", data=tips,
## 在其他情境中绘制回归
其他一些seaborn函数在更大,更复杂的图中使用[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")。第一个是我们在[发行教程](distributions.html#distribution-tutorial)中引入的[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")。除了前面讨论的绘制风格,[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") 可以使用[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")通过传递`kind="reg"`来显示轴上的线性回归拟合:
其他一些 seaborn 函数在更大,更复杂的图中使用[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")。第一个是我们在[发行教程](distributions.html#distribution-tutorial)中引入的[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")。除了前面讨论的绘制风格,[`jointplot()`](../generated/seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") 可以使用[`regplot()`](../generated/seaborn.regplot.html#seaborn.regplot "seaborn.regplot")通过传递`kind="reg"`来显示轴上的线性回归拟合:
```python
sns.jointplot(x="total_bill", y="tip", data=tips, kind="reg");
......
......@@ -24,7 +24,7 @@ seaborn.diverging_palette(h_neg, h_pos, s=75, l=50, sep=10, n=6, center='light',
`n`:int,可选
> 调色板中的颜色数(如果为not,返回一个colormap)
> 调色板中的颜色数(如果为 not,返回一个 colormap)
`center`:{“light”, “dark”}, 可选
......
......@@ -6,7 +6,7 @@
seaborn.xkcd_palette(colors)
```
使用来自xkcd color survey的颜色名字生成调色板。
使用来自 xkcd color survey 的颜色名字生成调色板。
查看完整的 xkcd 颜色列表: [https://xkcd.com/color/rgb/](https://xkcd.com/color/rgb/)
......
......@@ -25,4 +25,4 @@ seaborn.crayon_palette(colors)
另外
使用来自xkcd color survey的颜色名字创建调色板。
使用来自 xkcd color survey 的颜色名字创建调色板。
......@@ -2,11 +2,11 @@
> 译者:[keyianpai](https://github.com/keyianpai)
在探索中等维度数据时,经常需要在数据集的不同子集上绘制同一类型图的多个实例。这种技术有时被称为“网格”或“格子”绘图,它与[“多重小图”](https://en.wikipedia.org/wiki/Small_multiple)的概念有关。这种技术使查看者从复杂数据中快速提取大量信息。 Matplotlib为绘制这种多轴图提供了很好的支持; seaborn构建于此之上,可直接将绘图结构和数据集结构关系起来。
在探索中等维度数据时,经常需要在数据集的不同子集上绘制同一类型图的多个实例。这种技术有时被称为“网格”或“格子”绘图,它与[“多重小图”](https://en.wikipedia.org/wiki/Small_multiple)的概念有关。这种技术使查看者从复杂数据中快速提取大量信息。 Matplotlib 为绘制这种多轴图提供了很好的支持; seaborn 构建于此之上,可直接将绘图结构和数据集结构关系起来。
要使用网格图功能,数据必须在Pandas数据框中,并且必须采用 Hadley Whickam所谓的 [“整洁”数据](https://vita.had.co.nz/papers/tidy-data.pdf)的形式。简言之,用来画图的数据框应该构造成每列一个变量,每一行一个观察的形式。
要使用网格图功能,数据必须在 Pandas 数据框中,并且必须采用 Hadley Whickam 所谓的 [“整洁”数据](https://vita.had.co.nz/papers/tidy-data.pdf)的形式。简言之,用来画图的数据框应该构造成每列一个变量,每一行一个观察的形式。
至于高级用法,可以直接使用本教程中讨论的对象,以提供最大的灵活性。一些seaborn函数(例如`lmplot()``catplot()``pairplot()`)也在后台使用它们。与其他在没有操纵图形的情况下绘制到特定的(可能已经存在的)matplotlib `Axes`上的“Axes-level” seaborn函数不同,这些更高级别的函数在调用时会创建一个图形,并且通常对图形的设置方式更加严格。在某些情况下,这些函数或它们所依赖的类构造函数的参数将提供不同的接口属性,如`lmplot()`中的图形大小,你可以设置每个子图的高和宽高比。但是,使用这些对象的函数在绘图后都会返回它,并且这些对象大多都有方便简单的方法来改变图的绘制方式。
至于高级用法,可以直接使用本教程中讨论的对象,以提供最大的灵活性。一些 seaborn 函数(例如`lmplot()``catplot()``pairplot()`)也在后台使用它们。与其他在没有操纵图形的情况下绘制到特定的(可能已经存在的)matplotlib `Axes`上的“Axes-level” seaborn 函数不同,这些更高级别的函数在调用时会创建一个图形,并且通常对图形的设置方式更加严格。在某些情况下,这些函数或它们所依赖的类构造函数的参数将提供不同的接口属性,如`lmplot()`中的图形大小,你可以设置每个子图的高和宽高比。但是,使用这些对象的函数在绘图后都会返回它,并且这些对象大多都有方便简单的方法来改变图的绘制方式。
```py
import seaborn as sns
import matplotlib.pyplot as plt
......@@ -38,9 +38,9 @@ g = sns.FacetGrid(tips, col="time")
![http://seaborn.pydata.org/_images/axis_grids_7_0.png](img/98101f3cd02be71d90f9d777eca5876f.jpg)
如上初始化网格会设置matplotlib图形和轴,但不会在其上绘制任何内容。
如上初始化网格会设置 matplotlib 图形和轴,但不会在其上绘制任何内容。
在网格上可视化数据的主要方法是FacetGrid.map()。为此方法提供绘图函数以及要绘制的数据框变量名作为参数。我们使用直方图绘制每个子集中小费金额的分布。
在网格上可视化数据的主要方法是 FacetGrid.map()。为此方法提供绘图函数以及要绘制的数据框变量名作为参数。我们使用直方图绘制每个子集中小费金额的分布。
```py
g = sns.FacetGrid(tips, col="time")
g.map(plt.hist, "tip");
......@@ -69,7 +69,7 @@ g.map(sns.regplot, "size", "total_bill", color=".3", fit_reg=False, x_jitter=.1)
![http://seaborn.pydata.org/_images/axis_grids_13_0.png](img/8da0c248ec165400ddf3c27f13d9a824.jpg)
注意,matplotlib API并未正式支持`margin_titles`,此选项在一些情况下可能无法正常工作。特别是,它目前不能与图之外的图例同时使用。
注意,matplotlib API 并未正式支持`margin_titles`,此选项在一些情况下可能无法正常工作。特别是,它目前不能与图之外的图例同时使用。
通过提供每个面的高度以及纵横比来设置图形的大小:
```py
......@@ -86,7 +86,7 @@ g.map(sns.barplot, "sex", "total_bill");
![http://seaborn.pydata.org/_images/axis_grids_15_1.png](img/05a2ee4e2b81712775628943c2135066.jpg)
小图的默认排序由DataFrame中的信息确定的。如果用于定义小图的变量是类别变量,则使用类别的顺序。否则,小图将按照各类的出现顺序排列。但是,可以使用适当的`* _order`参数指定任意构面维度的顺序:
小图的默认排序由 DataFrame 中的信息确定的。如果用于定义小图的变量是类别变量,则使用类别的顺序。否则,小图将按照各类的出现顺序排列。但是,可以使用适当的`* _order`参数指定任意构面维度的顺序:
```py
ordered_days = tips.day.value_counts().index
g = sns.FacetGrid(tips, row="day", row_order=ordered_days,
......@@ -97,7 +97,7 @@ g.map(sns.distplot, "total_bill", hist=False, rug=True);
![http://seaborn.pydata.org/_images/axis_grids_17_0.png](img/0140b6849cae4a202c9a56ad5edfffd6.jpg)
可以用seaborn调色板(即可以传递给[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")的东西。)还可以用字典将`hue`变量中的值映射到matplotlib颜色:
可以用 seaborn 调色板(即可以传递给[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")的东西。)还可以用字典将`hue`变量中的值映射到 matplotlib 颜色:
```py
pal = dict(Lunch="seagreen", Dinner="gray")
g = sns.FacetGrid(tips, hue="time", palette=pal, height=5)
......@@ -108,7 +108,7 @@ g.add_legend();
![http://seaborn.pydata.org/_images/axis_grids_19_0.png](img/686b61f7ba884a08ccd40cd9aae45791.jpg)
还可以让图的其他方面(如点的形状)在色调变量的各个级别之间变化,这在以黑白方式打印时使图易于理解。为此,只需将一个字典传递给hue_kws,其中键是绘图函数关键字参数的名称,值是关键字值列表,每个级别为一个色调变量。
还可以让图的其他方面(如点的形状)在色调变量的各个级别之间变化,这在以黑白方式打印时使图易于理解。为此,只需将一个字典传递给 hue_kws,其中键是绘图函数关键字参数的名称,值是关键字值列表,每个级别为一个色调变量。
```py
g = sns.FacetGrid(tips, hue="sex", palette="Set1", height=5, hue_kws={"marker": ["^", "v"]})
g.map(plt.scatter, "total_bill", "tip", s=100, linewidth=.5, edgecolor="white")
......@@ -118,7 +118,7 @@ g.add_legend();
![http://seaborn.pydata.org/_images/axis_grids_21_0.png](img/a99d865fc52a457633d59e779fb194f1.jpg)
如果一个变量的水平数过多,除了可以沿着列绘制之外,也可以“包装”它们以便它们跨越多行。执行此wrap操作时,不能使用`row`变量。
如果一个变量的水平数过多,除了可以沿着列绘制之外,也可以“包装”它们以便它们跨越多行。执行此 wrap 操作时,不能使用`row`变量。
```py
attend = sns.load_dataset("attention").query("subject <= 12")
g = sns.FacetGrid(attend, col="subject", col_wrap=4, height=2, ylim=(0, 10))
......@@ -147,7 +147,7 @@ g.fig.subplots_adjust(wspace=.02, hspace=.02);
![http://seaborn.pydata.org/_images/axis_grids_25_0.png](img/9127880f623ed92358326c68893d22b4.jpg)
对于需要更多自定义的情形,你可以直接使用底层matplotlib图形`Figure`和轴`Axes`对象,它们分别作为成员属性存储在`Figure`和轴`Axes`(一个二维数组)中。在制作没有行或列刻面的图形时,你还可以使用`ax`属性直接访问单个轴。
对于需要更多自定义的情形,你可以直接使用底层 matplotlib 图形`Figure`和轴`Axes`对象,它们分别作为成员属性存储在`Figure`和轴`Axes`(一个二维数组)中。在制作没有行或列刻面的图形时,你还可以使用`ax`属性直接访问单个轴。
```py
g = sns.FacetGrid(tips, col="smoker", margin_titles=True, height=4)
......@@ -162,9 +162,9 @@ g.set(xlim=(0, 60), ylim=(0, 14));
## 使用自定义函数
使用[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")时,你除了可以使用现有的matplotlib和seaborn函数,还可以使用自定义函数。但是,这些函数必须遵循一些规则:
使用[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")时,你除了可以使用现有的 matplotlib 和 seaborn 函数,还可以使用自定义函数。但是,这些函数必须遵循一些规则:
1. 它必须绘制到“当前活动的”matplotlib轴`Axes`上。 `matplotlib.pyplot`命名空间中的函数就是如此。如果要直接使用当前轴的方法,可以调用`plt.gca`来获取对当前`Axes`的引用。
1. 它必须绘制到“当前活动的”matplotlib `Axes`上。 `matplotlib.pyplot`命名空间中的函数就是如此。如果要直接使用当前轴的方法,可以调用`plt.gca`来获取对当前`Axes`的引用。
2. 它必须接受它在位置参数中绘制的数据。在内部,[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")将为传递给[`FacetGrid.map()`](../generated/seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")的每个命名位置参数传递一`Series`数据。
3. 它必须能接受`color``label`关键字参数,理想情况下,它会用它们做一些有用的事情。在大多数情况下,最简单的方法是捕获`** kwargs`的通用字典并将其传递给底层绘图函数。
......@@ -182,7 +182,7 @@ g.map(quantile_plot, "total_bill");
![http://seaborn.pydata.org/_images/axis_grids_29_0.png](img/f7075e926868bca0186de8da2f906ed9.jpg)
如果你想要制作一个双变量图,编写函数则应该有分别接受x轴变量,y轴变量的参数:
如果你想要制作一个双变量图,编写函数则应该有分别接受 x 轴变量,y 轴变量的参数:
```py
def qqplot(x, y, **kwargs):
_, xr = stats.probplot(x, fit=False)
......@@ -217,7 +217,7 @@ g.add_legend();
![http://seaborn.pydata.org/_images/axis_grids_35_0.png](img/894a1105419e7147b562c1576471c410.jpg)
有时候,你需要使用`color``label`关键字参数映射不能按预期方式工作的函数。在这种情况下,你需要显式捕获它们并在自定义函数的逻辑中处理它们。例如,这种方法可用于映射`plt.hexbin`,使它与[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") API匹配:
有时候,你需要使用`color``label`关键字参数映射不能按预期方式工作的函数。在这种情况下,你需要显式捕获它们并在自定义函数的逻辑中处理它们。例如,这种方法可用于映射`plt.hexbin`,使它与[`FacetGrid`](../generated/seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") API 匹配:
```py
def hexbin(x, y, color, **kwargs):
cmap = sns.light_palette(color, as_cmap=True)
......@@ -258,7 +258,7 @@ g.map_offdiag(plt.scatter);
![http://seaborn.pydata.org/_images/axis_grids_41_0.png](img/e6b76ab1dc666e53ba77d9784aa8d168.jpg)
此图的一种常见用法是通过单独的分类变量对观察结果进行着色。例如,iris数据集三种不同种类的鸢尾花都有四种测量值,因此你可以看到不同花在这些取值上的差异。
此图的一种常见用法是通过单独的分类变量对观察结果进行着色。例如,iris 数据集三种不同种类的鸢尾花都有四种测量值,因此你可以看到不同花在这些取值上的差异。
```py
g = sns.PairGrid(iris, hue="species")
g.map_diag(plt.hist)
......@@ -309,7 +309,7 @@ g.add_legend();
![http://seaborn.pydata.org/_images/axis_grids_51_0.png](img/472e90723a05c450ec78ccf39888e6e4.jpg)
[`PairGrid`](../generated/seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")很灵活,但要快速查看数据集,使用[`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot")更容易。此函数默认使用散点图和直方图,但会添加一些其他类型(目前,你还可以绘制非对角线上的回归图和对角线上的KDE)。
[`PairGrid`](../generated/seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")很灵活,但要快速查看数据集,使用[`pairplot()`](../generated/seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot")更容易。此函数默认使用散点图和直方图,但会添加一些其他类型(目前,你还可以绘制非对角线上的回归图和对角线上的 KDE)。
```py
sns.pairplot(iris, hue="species", height=2.5);
......
......@@ -10,11 +10,11 @@ seaborn.load_dataset(name, cache=True, data_home=None, **kws)
参数:`name`:字符串
> 数据集的名字 (&lt;cite&gt;name&lt;/cite&gt;.csv on [https://github.com/mwaskom/seaborn-data](https://github.com/mwaskom/seaborn-data))。 您可以通过 `get_dataset_names()` 获取可用的数据集。
> 数据集的名字 (`name`.csv on [https://github.com/mwaskom/seaborn-data](https://github.com/mwaskom/seaborn-data))。 您可以通过 `get_dataset_names()` 获取可用的数据集。
`cache`:boolean, 可选
> 如果为True,则在本地缓存数据并在后续调用中使用缓存。
> 如果为 True,则在本地缓存数据并在后续调用中使用缓存。
`data_home`:string, 可选
......
......@@ -36,7 +36,7 @@ offset : int or dict, 可选
trim : bool, 可选
```
如果为True,则将脊柱限制为每个非去除脊柱的轴上的最小和最大主刻度。
如果为 True,则将脊柱限制为每个非去除脊柱的轴上的最小和最大主刻度。
返回值:None |
| --- | --- |
......@@ -10,7 +10,7 @@ seaborn.desaturate(color, prop)
参数:`color`:matplotlib 颜色
> 十六进制,rgb 元组或者html颜色名字
> 十六进制,rgb 元组或者 html 颜色名字
`prop`:float
......@@ -18,5 +18,5 @@ seaborn.desaturate(color, prop)
返回值:`new_color`:rgb 元组
> RGB元组表示去饱和的颜色代码
> RGB 元组表示去饱和的颜色代码
......@@ -10,10 +10,10 @@ seaborn.saturate(color)
参数:`color`:matplotlib 颜色
> 十六进制,rgb 元组或者html颜色名字
> 十六进制,rgb 元组或者 html 颜色名字
返回值:`new_color`:rgb 元组
> RGB元组表示的饱和颜色代码
> RGB 元组表示的饱和颜色代码
......@@ -10,7 +10,7 @@ seaborn.set_hls_values(color, h=None, l=None, s=None)
参数:`color`:matplotlib 颜色
> 十六进制,rgb 元组或者html颜色名字
> 十六进制,rgb 元组或者 html 颜色名字
`h, l, s`:0 到 1 之间的浮点数,或者为 None
......@@ -19,5 +19,5 @@ seaborn.set_hls_values(color, h=None, l=None, s=None)
返回值:`new_color`:rgb 元组
> RGB元组表示中的新颜色代码
> RGB 元组表示中的新颜色代码
......@@ -4,7 +4,7 @@
绘制有吸引力的图像很十分重要的。当你在探索一个数据集并为你自己做图的时候,制作一些让人看了心情愉悦的图像是很好的。可视化对向观众传达量化的简介也是很重要的,在这种情况下制作能够抓住查看者的注意力并牢牢吸引住他们的图像就更有必要了。
Matplotlib是高度可定制的,但是很难知道要如何设置图像才能使得图像更加吸引人。Seaborn提供了许多定制好的主题和高级的接口,用于控制Matplotlib所做图像的外观。
Matplotlib 是高度可定制的,但是很难知道要如何设置图像才能使得图像更加吸引人。Seaborn 提供了许多定制好的主题和高级的接口,用于控制 Matplotlib 所做图像的外观。
```py
import numpy as np
......@@ -23,7 +23,7 @@ def sinplot(flip=1):
```
这是Matplotlib默认情况下的绘图外观:
这是 Matplotlib 默认情况下的绘图外观:
```py
sinplot()
......@@ -32,7 +32,7 @@ sinplot()
![http://seaborn.pydata.org/_images/aesthetics_7_0.png](img/4784d932a8738cea5085be56ce6f7315.jpg)
为了将图像的风格转变为seaborn的默认样式,我们可以 [`set()`](../generated/seaborn.set.html#seaborn.set "seaborn.set") 函数。
为了将图像的风格转变为 seaborn 的默认样式,我们可以 [`set()`](../generated/seaborn.set.html#seaborn.set "seaborn.set") 函数。
```py
sns.set()
......@@ -42,15 +42,15 @@ sinplot()
![http://seaborn.pydata.org/_images/aesthetics_9_0.png](img/2422a0c0d2c96ec6397babaa6c842d79.jpg)
(注意,在0.8之前的seaborn版本中, [`set()`](../generated/seaborn.set.html#seaborn.set "seaborn.set") 已经在使用impory语句导入的时候就被调用了。但在以后的版本中,必须要显式调用它)。
(注意,在 0.8 之前的 seaborn 版本中, [`set()`](../generated/seaborn.set.html#seaborn.set "seaborn.set") 已经在使用 impory 语句导入的时候就被调用了。但在以后的版本中,必须要显式调用它)。
Seaborn将matplotlib参数分成两个独立的组。第一组设置了图像的美术风格,第二组则对图像中不同的元素进行了控制,使得图像可以很容易地融入不同的环境中。
Seaborn 将 matplotlib 参数分成两个独立的组。第一组设置了图像的美术风格,第二组则对图像中不同的元素进行了控制,使得图像可以很容易地融入不同的环境中。
操作这些参数的接口是两对函数。要控制样式,请使用 [`axes_style()`](../generated/seaborn.axes_style.html#seaborn.axes_style "seaborn.axes_style")[`set_style()`](../generated/seaborn.set_style.html#seaborn.set_style "seaborn.set_style") 函数。要对图像中元素的样式进行修改,请使用 [`plotting_context()`](../generated/seaborn.plotting_context.html#seaborn.plotting_context "seaborn.plotting_context")[`set_context()`](../generated/seaborn.set_context.html#seaborn.set_context "seaborn.set_context") 函数。在这两种情况下(控制图像样式与修改元素样式),第一个函数会返回一个参数字典,第二个函数设置matplotlib中相关参数的默认值。
操作这些参数的接口是两对函数。要控制样式,请使用 [`axes_style()`](../generated/seaborn.axes_style.html#seaborn.axes_style "seaborn.axes_style")[`set_style()`](../generated/seaborn.set_style.html#seaborn.set_style "seaborn.set_style") 函数。要对图像中元素的样式进行修改,请使用 [`plotting_context()`](../generated/seaborn.plotting_context.html#seaborn.plotting_context "seaborn.plotting_context")[`set_context()`](../generated/seaborn.set_context.html#seaborn.set_context "seaborn.set_context") 函数。在这两种情况下(控制图像样式与修改元素样式),第一个函数会返回一个参数字典,第二个函数设置 matplotlib 中相关参数的默认值。
## Seaborn图像参数
## Seaborn 图像参数
有五个预设的Seaborn主题: `darkgrid``whitegrid``dark``white`以及 `ticks`。它们分别适用于不同的应用程序和个人偏好。默认主题为 `darkgrid`。如上所述,坐标方格有助于将制出的图像用作定量信息的查阅表,灰色背景上的白色有助于防止网格与表示数据的行发生竞争。 `whitegrid` 主题类似,但它更适用于包含大量数据元素的绘图:
有五个预设的 Seaborn 主题: `darkgrid``whitegrid``dark``white`以及 `ticks`。它们分别适用于不同的应用程序和个人偏好。默认主题为 `darkgrid`。如上所述,坐标方格有助于将制出的图像用作定量信息的查阅表,灰色背景上的白色有助于防止网格与表示数据的行发生竞争。 `whitegrid` 主题类似,但它更适用于包含大量数据元素的绘图:
```py
sns.set_style("whitegrid")
......@@ -79,7 +79,7 @@ sinplot()
![http://seaborn.pydata.org/_images/aesthetics_14_0.png](img/47decb21ce3a9413876a02f2967ef7aa.jpg)
有时,您可能希望为绘图提供一点额外的结构,这正是tick样式的用武之地:
有时,您可能希望为绘图提供一点额外的结构,这正是 tick 样式的用武之地:
```py
sns.set_style("ticks")
......@@ -91,7 +91,7 @@ sinplot()
## 移除坐标轴
`white` 样式与 `ticks` 样式的好处是都能删除所不需要的顶部与右部坐标轴。使用seaborn中的函数 [`despine()`](../generated/seaborn.despine.html#seaborn.despine "seaborn.despine") 可以来移除它们:
`white` 样式与 `ticks` 样式的好处是都能删除所不需要的顶部与右部坐标轴。使用 seaborn 中的函数 [`despine()`](../generated/seaborn.despine.html#seaborn.despine "seaborn.despine") 可以来移除它们:
```py
sinplot()
......@@ -139,9 +139,9 @@ sinplot(-1)
![http://seaborn.pydata.org/_images/aesthetics_24_0.png](img/1b8ec9b9fb72e9193bfefe933d976d37.jpg)
## 覆盖控制seaborn样式的元素
## 覆盖控制 seaborn 样式的元素
如果你想要自己定制seaborn的样式,你可以通过给 [`axes_style()`](../generated/seaborn.axes_style.html#seaborn.axes_style "seaborn.axes_style")[`set_style()`](../generated/seaborn.set_style.html#seaborn.set_style "seaborn.set_style")函数中的 `rc` 参数传递一个参数字典来实现。请注意,您只能通过此方法覆盖作为样式定义一部分的参数。(但是,更高级别的 [`set()`](../generated/seaborn.set.html#seaborn.set "seaborn.set") 函数会获取任何matplotlib参数的字典)。
如果你想要自己定制 seaborn 的样式,你可以通过给 [`axes_style()`](../generated/seaborn.axes_style.html#seaborn.axes_style "seaborn.axes_style")[`set_style()`](../generated/seaborn.set_style.html#seaborn.set_style "seaborn.set_style")函数中的 `rc` 参数传递一个参数字典来实现。请注意,您只能通过此方法覆盖作为样式定义一部分的参数。(但是,更高级别的 [`set()`](../generated/seaborn.set.html#seaborn.set "seaborn.set") 函数会获取任何 matplotlib 参数的字典)。
如果你想看看包含哪些参数,你可以只调用没有参数的函数,这将返回当前设置:
......
......@@ -2,9 +2,9 @@
> 译者:[Modrisco](https://github.com/Modrisco)
颜色在图像风格中比起其他元素显得更为重要。当合理有效地使用颜色时,数据模式会被凸显出来;反之,则会被掩盖。这里有很多数据可视化中关于颜色使用的优秀资源,我推荐阅读这些 Rob Simmon 的[博客文章](https://earthobservatory.nasa.gov/blogs/elegantfigures/2013/08/05/subtleties-of-color-part-1-of-6/)以及这篇更加学术性的[论文](https://cfwebprod.sandia.gov/cfdocs/CompResearch/docs/ColorMapsExpanded.pdf)。 此外,matplotlib 文档也提供了一篇很好的[教程](https://matplotlib.org/users/colormaps.html)来说明一些内置Colormap的感知属性。
颜色在图像风格中比起其他元素显得更为重要。当合理有效地使用颜色时,数据模式会被凸显出来;反之,则会被掩盖。这里有很多数据可视化中关于颜色使用的优秀资源,我推荐阅读这些 Rob Simmon 的[博客文章](https://earthobservatory.nasa.gov/blogs/elegantfigures/2013/08/05/subtleties-of-color-part-1-of-6/)以及这篇更加学术性的[论文](https://cfwebprod.sandia.gov/cfdocs/CompResearch/docs/ColorMapsExpanded.pdf)。 此外,matplotlib 文档也提供了一篇很好的[教程](https://matplotlib.org/users/colormaps.html)来说明一些内置 Colormap 的感知属性。
seaborn让您在选择与您处理的数据类型和可视化过程中搭配的配色方案变得简单。
seaborn 让您在选择与您处理的数据类型和可视化过程中搭配的配色方案变得简单。
```py
import numpy as np
......@@ -16,21 +16,21 @@ sns.set()
## 创建调色板
使用离散调色板过程中最重要函数是[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")。这个函数为许多(但不是全部)可以在seaborn中生成颜色的方式提供了一个接口,并且在任何具有`palette`参数的函数的内部都可以使用(以及某些需要多种颜色时具有`color`参数的情况)。
使用离散调色板过程中最重要函数是[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")。这个函数为许多(但不是全部)可以在 seaborn 中生成颜色的方式提供了一个接口,并且在任何具有`palette`参数的函数的内部都可以使用(以及某些需要多种颜色时具有`color`参数的情况)。
[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 会接受所有的seaborn调色板或者matplotlib Colormap (除了 `jet`, 您永远都不应该使用它). 它还可以获取以任何有效matplotlib格式(RGB元组、十六进制颜色代码或HTML颜色名字)指定的颜色列表。返回值始终是RGB元组的列表。
[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 会接受所有的 seaborn 调色板或者 matplotlib Colormap (除了 `jet`, 您永远都不应该使用它). 它还可以获取以任何有效 matplotlib 格式(RGB 元组、十六进制颜色代码或 HTML 颜色名字)指定的颜色列表。返回值始终是 RGB 元组的列表。
最后,在没有参数的情况下调用[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数将会返回当前默认的颜色循环。
函数[`set_palette()`](../generated/seaborn.set_palette.html#seaborn.set_palette "seaborn.set_palette")接受相同的参数,并将为所有图像设置默认的颜色循环。您也可以在`with`语句中调用[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")来临时改变调色板。([参见](#palette-contexts))
在不了解数据特征的情况下,通常也不可能知道哪种调色板或Colormap最适合一组数据。接下来,我们将通过三种常见的调色板 _定性调色板_, _顺序调色板_, 和 _发散调色板_ 来拆分介绍[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数的使用方法以及其他seaborn函数。
在不了解数据特征的情况下,通常也不可能知道哪种调色板或 Colormap 最适合一组数据。接下来,我们将通过三种常见的调色板 _ 定性调色板 _, _ 顺序调色板 _, 和 _ 发散调色板 _ 来拆分介绍[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数的使用方法以及其他 seaborn 函数。
## 定性调色板
当您想要区分不具有内在顺序的离散数据块时,定性(分类)调色板是最佳方案。
导入seaborn的同时,会引入默认的颜色循环,由6种颜色构成。并将调用标准matplotlib颜色循环,看起来也更加赏心悦目。
导入 seaborn 的同时,会引入默认的颜色循环,由 6 种颜色构成。并将调用标准 matplotlib 颜色循环,看起来也更加赏心悦目。
```py
current_palette = sns.color_palette()
......@@ -46,9 +46,9 @@ sns.palplot(current_palette)
### 使用循环颜色系统
当您要区分任意数量的类别而不强调任何类别时,最简单的方法是在循环颜色空间中绘制间距相等的颜色(在此颜色空间中,色调会发生变化,同时保持亮度和饱和度不变)。这是大多数seaborn函数在处理当需要区分的数据集超过颜色循环中的6种颜色时时所使用的默认方法。
当您要区分任意数量的类别而不强调任何类别时,最简单的方法是在循环颜色空间中绘制间距相等的颜色(在此颜色空间中,色调会发生变化,同时保持亮度和饱和度不变)。这是大多数 seaborn 函数在处理当需要区分的数据集超过颜色循环中的 6 种颜色时时所使用的默认方法。
最为常用的方法是使用`hls`颜色空间——一种简单的RGB值变体。
最为常用的方法是使用`hls`颜色空间——一种简单的 RGB 值变体。
```py
sns.palplot(sns.color_palette("hls", 8))
......@@ -66,9 +66,9 @@ sns.palplot(sns.hls_palette(8, l=.3, s=.8))
![http://seaborn.pydata.org/_images/color_palettes_12_0.png](img/7787cf3ad144a10c16ce1f2697d4af34.jpg)
然而,由于人类视觉系统的工作方式,RGB强度很高的颜色也不一定看起来同样强烈。[我们认为](https://en.wikipedia.org/wiki/Color_vision)黄色和绿色是相对较亮的,蓝色是相对较暗的,当目标是与`hls`系统保持一致性时可能会带来一些问题。
然而,由于人类视觉系统的工作方式,RGB 强度很高的颜色也不一定看起来同样强烈。[我们认为](https://en.wikipedia.org/wiki/Color_vision)黄色和绿色是相对较亮的,蓝色是相对较暗的,当目标是与`hls`系统保持一致性时可能会带来一些问题。
为了解决这一问题,seaborn提供了一个[husl](http://www.hsluv.org/)系统(后来更名为HSLuv)的接口,这也使选择间隔均匀的色调变得容易,同时使亮度和饱和度都更加均匀。
为了解决这一问题,seaborn 提供了一个[husl](http://www.hsluv.org/)系统(后来更名为 HSLuv)的接口,这也使选择间隔均匀的色调变得容易,同时使亮度和饱和度都更加均匀。
```py
sns.palplot(sns.color_palette("husl", 8))
......@@ -79,11 +79,11 @@ sns.palplot(sns.color_palette("husl", 8))
类似地,[`husl_palette()`](../generated/seaborn.husl_palette.html#seaborn.husl_palette "seaborn.husl_palette")函数也为这个系统提供了一个更灵活的接口。
### 使用Color Brewer调色板
### 使用 Color Brewer 调色板
[Color Brewer](http://colorbrewer2.org/)为定性调色板提供了另一种美观的配色方案(同样包含顺序调色板包括和发散调色板,详情见下文)。这些也作为matplotlib Colormap存在,但并没有得到很好的处理。在seaborn中,当您需要定性(qualitative)的Color Brewer方案时,你总是会得到离散的颜色,但这意味着在某些情况下颜色会循环重复。
[Color Brewer](http://colorbrewer2.org/)为定性调色板提供了另一种美观的配色方案(同样包含顺序调色板包括和发散调色板,详情见下文)。这些也作为 matplotlib Colormap 存在,但并没有得到很好的处理。在 seaborn 中,当您需要定性(qualitative)的 Color Brewer 方案时,你总是会得到离散的颜色,但这意味着在某些情况下颜色会循环重复。
Color Brewer的一个很好的特点是它对色盲比较友好。[色盲](https:/en.wikipea.org/wiki/Color_Blinity)有很多种,最为常见的是红绿色盲。通常,对于需要根据颜色进行元素区分时,应该尽量避免使用这两种颜色。
Color Brewer 的一个很好的特点是它对色盲比较友好。[色盲](https:/en.wikipea.org/wiki/Color_Blinity)有很多种,最为常见的是红绿色盲。通常,对于需要根据颜色进行元素区分时,应该尽量避免使用这两种颜色。
```py
sns.palplot(sns.color_palette("Paired"))
......@@ -99,7 +99,7 @@ sns.palplot(sns.color_palette("Set2"))
![http://seaborn.pydata.org/_images/color_palettes_17_0.png](img/8d928f7a998a90772bc3defd036444a8.jpg)
为了帮助您从Color Brewer库中选取配色方案,seaborn提供了[`choose_colorbrewer_palette()`](../generated/seaborn.choose_colorbrewer_palette.html#seaborn.choose_colorbrewer_palette "seaborn.choose_colorbrewer_palette")函数。这个函数能够启动交互式组件来帮助您浏览各种选项,修改不同的参数。但是只能在Jupyter notebook中使用。
为了帮助您从 Color Brewer 库中选取配色方案,seaborn 提供了[`choose_colorbrewer_palette()`](../generated/seaborn.choose_colorbrewer_palette.html#seaborn.choose_colorbrewer_palette "seaborn.choose_colorbrewer_palette")函数。这个函数能够启动交互式组件来帮助您浏览各种选项,修改不同的参数。但是只能在 Jupyter notebook 中使用。
当然,您可能只希望手动指定一组您喜欢的颜色。[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数会接受一个颜色列表,操作起来也很简单。
......@@ -111,9 +111,9 @@ sns.palplot(sns.color_palette(flatui))
![http://seaborn.pydata.org/_images/color_palettes_19_0.png](img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg)
### 使用来自xkcd color survey的颜色名字
### 使用来自 xkcd color survey 的颜色名字
不久前,[xkcd](https://xkcd.com/)开展了一项[众包工作](https://blog.xkcd.com/2010/05/03/color-survey-results/)来为随机RGB颜色命名。产生了[954个颜色名字](https://xkcd.com/color/rgb/),您现在可以在seaborn中使用`xkcd_rgb`字典来引用它们:
不久前,[xkcd](https://xkcd.com/)开展了一项[众包工作](https://blog.xkcd.com/2010/05/03/color-survey-results/)来为随机 RGB 颜色命名。产生了[954 个颜色名字](https://xkcd.com/color/rgb/),您现在可以在 seaborn 中使用`xkcd_rgb`字典来引用它们:
```py
plt.plot([0, 1], [0, 1], sns.xkcd_rgb["pale red"], lw=3)
......@@ -136,13 +136,13 @@ sns.palplot(sns.xkcd_palette(colors))
## 顺序调色板
第二类主要的调色板被称为“顺序调色板”(sequential),当数据集的范围从相对低值(不感兴趣)到相对高值(很感兴趣)时,最好使用顺序调色板,尽管在某些情况下您可能需要顺序调色板中的离散颜色。在[`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")[`heatmap()`](../generated/seaborn.heatmap.html#seaborn.heatmap "seaborn.heatmap")函数中使用它们来作为Colormap则更为常见(以及类似的matplotlib函数)。
第二类主要的调色板被称为“顺序调色板”(sequential),当数据集的范围从相对低值(不感兴趣)到相对高值(很感兴趣)时,最好使用顺序调色板,尽管在某些情况下您可能需要顺序调色板中的离散颜色。在[`kdeplot()`](../generated/seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")[`heatmap()`](../generated/seaborn.heatmap.html#seaborn.heatmap "seaborn.heatmap")函数中使用它们来作为 Colormap 则更为常见(以及类似的 matplotlib 函数)。
在这种情况下使用`jet`(或其他彩虹调色板)等Colormap是很常见的,因为色调范围给人的印象是提供有关数据的额外信息。然而,具有较大色调变化的Colormap往往会引入数据中不存在的不连续性,并且我们的视觉系统无法自然地将彩虹光谱映射到诸如“高”或“低”的定量区分。导致来这些可视化的结果更加令人困惑,因为它们掩盖了数据中的模式,而不是揭示它们。`jet` 调色板使用了最亮的颜色(黄色和青色)的中间数据值,导致效果是强调无趣的(和任意的)值,而不是强调极端的值。
在这种情况下使用`jet`(或其他彩虹调色板)等 Colormap 是很常见的,因为色调范围给人的印象是提供有关数据的额外信息。然而,具有较大色调变化的 Colormap 往往会引入数据中不存在的不连续性,并且我们的视觉系统无法自然地将彩虹光谱映射到诸如“高”或“低”的定量区分。导致来这些可视化的结果更加令人困惑,因为它们掩盖了数据中的模式,而不是揭示它们。`jet` 调色板使用了最亮的颜色(黄色和青色)的中间数据值,导致效果是强调无趣的(和任意的)值,而不是强调极端的值。
对于连续性的数据,最好使用色调变化幅度较小,而亮度和饱和度变化幅度较大的配色方案。这种方法会很自然地吸引人们注意数据中相对重要的部分。
Color Brewer库有大量这样的配色方案,它们以调色板中主要的一种或多种颜色命名。
Color Brewer 库有大量这样的配色方案,它们以调色板中主要的一种或多种颜色命名。
```py
sns.palplot(sns.color_palette("Blues"))
......@@ -151,7 +151,7 @@ sns.palplot(sns.color_palette("Blues"))
![http://seaborn.pydata.org/_images/color_palettes_25_0.png](img/b6ac2dda5753920442b42aa6c3f8746c.jpg)
matplotlib类似,您可以通过添加加后缀`_r`来倒置顺序调色板的顺序。
matplotlib 类似,您可以通过添加加后缀`_r`来倒置顺序调色板的顺序。
```py
sns.palplot(sns.color_palette("BuGn_r"))
......@@ -160,7 +160,7 @@ sns.palplot(sns.color_palette("BuGn_r"))
![http://seaborn.pydata.org/_images/color_palettes_27_0.png](img/35ba6c0dab54401105c2b869de17084b.jpg)
seaborn同样添加了一个小窍门来帮助您创建“深色”调色板,它没有一个很宽的动态范围。在当您需要按顺序映射直线或点时这可能会很有用,因为颜色较亮的线条会比较难以区分。
seaborn 同样添加了一个小窍门来帮助您创建“深色”调色板,它没有一个很宽的动态范围。在当您需要按顺序映射直线或点时这可能会很有用,因为颜色较亮的线条会比较难以区分。
```py
sns.palplot(sns.color_palette("GnBu_d"))
......@@ -169,13 +169,13 @@ sns.palplot(sns.color_palette("GnBu_d"))
![http://seaborn.pydata.org/_images/color_palettes_29_0.png](img/12d91b101a0391d48ce055f66e4a910a.jpg)
您可能想要使用[`choose_colorbrewer_palette()`](../generated/seaborn.choose_colorbrewer_palette.html#seaborn.choose_colorbrewer_palette "seaborn.choose_colorbrewer_palette")函数来尝试多种选项,当您希望传递给seaborn或者matplotlib的返回值为Colormap对象时,您可以将`as_cmap`对象设置为`True`
您可能想要使用[`choose_colorbrewer_palette()`](../generated/seaborn.choose_colorbrewer_palette.html#seaborn.choose_colorbrewer_palette "seaborn.choose_colorbrewer_palette")函数来尝试多种选项,当您希望传递给 seaborn 或者 matplotlib 的返回值为 Colormap 对象时,您可以将`as_cmap`对象设置为`True`
### 顺序 “cubehelix” 调色板
[cubehelix](https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)调色板系统使顺序调色板的亮度产生线性变化,色调也会产生一些变化。这意味着您的Colormap在转换为黑白模式时(用于打印)的信息将得到保留,且对色盲友好。
[cubehelix](https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)调色板系统使顺序调色板的亮度产生线性变化,色调也会产生一些变化。这意味着您的 Colormap 在转换为黑白模式时(用于打印)的信息将得到保留,且对色盲友好。
Matplotlib内置了默认的cubehelix版本:
Matplotlib 内置了默认的 cubehelix 版本:
```py
sns.palplot(sns.color_palette("cubehelix", 8))
......@@ -184,9 +184,9 @@ sns.palplot(sns.color_palette("cubehelix", 8))
![http://seaborn.pydata.org/_images/color_palettes_32_0.png](img/d07b38f860b0f58e365e7ea26da8be92.jpg)
Seborn为cubehelix系统提供了一个接口,以便您可以制作各种调色板,这些调色板都具有良好的线性亮度渐变。
Seborn 为 cubehelix 系统提供了一个接口,以便您可以制作各种调色板,这些调色板都具有良好的线性亮度渐变。
seborn [`cubehelix_palette()`](../generated/seaborn.cubehelix_palette.html#seaborn.cubehelix_palette "seaborn.cubehelix_palette") 函数返回的默认调色板与matplotlib的默认值稍有不同,因为它不会围绕色轮旋转很远,也不会覆盖很宽的强度范围。它还反转顺序,以便让更重要的值的颜色更暗:
seborn [`cubehelix_palette()`](../generated/seaborn.cubehelix_palette.html#seaborn.cubehelix_palette "seaborn.cubehelix_palette") 函数返回的默认调色板与 matplotlib 的默认值稍有不同,因为它不会围绕色轮旋转很远,也不会覆盖很宽的强度范围。它还反转顺序,以便让更重要的值的颜色更暗:
```py
sns.palplot(sns.cubehelix_palette(8))
......@@ -194,7 +194,7 @@ sns.palplot(sns.cubehelix_palette(8))
![http://seaborn.pydata.org/_images/color_palettes_34_0.png](img/be20ca200667c3c8849b95c4a6aa846e.jpg)
[`cubehelix_palette()`](../generated/seaborn.cubehelix_palette.html#seaborn.cubehelix_palette "seaborn.cubehelix_palette") 函数的其他参数控制调色板的外观。您将更改的两个主要参数为 `start` (介于0到3之间的值)和 `rot` —— 旋转次数(任意值,但可能在-1和1之间)。
[`cubehelix_palette()`](../generated/seaborn.cubehelix_palette.html#seaborn.cubehelix_palette "seaborn.cubehelix_palette") 函数的其他参数控制调色板的外观。您将更改的两个主要参数为 `start` (介于 0 到 3 之间的值)和 `rot` —— 旋转次数(任意值,但可能在-1 和 1 之间)。
```py
sns.palplot(sns.cubehelix_palette(8, start=.5, rot=-.75))
......@@ -212,7 +212,7 @@ sns.palplot(sns.cubehelix_palette(8, start=2, rot=0, dark=0, light=.95, reverse=
![http://seaborn.pydata.org/_images/color_palettes_38_0.png](img/c4e8f173e5519de01ed11bca06911371.jpg)
如同其他seaborn函数,您将默认得到一个颜色列表。但您也可以通过修改 `as_cmap=True` 将调色板作为Colormap对象的返回值来传递给seaborn或matplotlib函数。
如同其他 seaborn 函数,您将默认得到一个颜色列表。但您也可以通过修改 `as_cmap=True` 将调色板作为 Colormap 对象的返回值来传递给 seaborn 或 matplotlib 函数。
```py
x, y = np.random.multivariate_normal([0, 0], [[1, -.5], [-.5, 1]], size=300).T
......@@ -223,7 +223,7 @@ sns.kdeplot(x, y, cmap=cmap, shade=True);
![http://seaborn.pydata.org/_images/color_palettes_40_0.png](img/2e48cfc09dde0559e31096f5a067ad3d.jpg)
为了帮助您选择更好的调色板或者Colormap,您可以在Jupyter notebook中使用 [`choose_cubehelix_palette()`](../generated/seaborn.choose_cubehelix_palette.html#seaborn.choose_cubehelix_palette "seaborn.choose_cubehelix_palette") 函数来启动互动界面帮助您测试、修改不同的参数。如果您希望函数返回一个Colormap(而不是列表),则在例如像 `hexbin` 这样的函数中设置 `as_Cmap=True`
为了帮助您选择更好的调色板或者 Colormap,您可以在 Jupyter notebook 中使用 [`choose_cubehelix_palette()`](../generated/seaborn.choose_cubehelix_palette.html#seaborn.choose_cubehelix_palette "seaborn.choose_cubehelix_palette") 函数来启动互动界面帮助您测试、修改不同的参数。如果您希望函数返回一个 Colormap(而不是列表),则在例如像 `hexbin` 这样的函数中设置 `as_Cmap=True`
### 自定义调色板
......@@ -252,7 +252,7 @@ sns.palplot(sns.light_palette("navy", reverse=True))
![http://seaborn.pydata.org/_images/color_palettes_46_0.png](img/c32dd39f791f7d395dc47b37e1252b78.jpg)
这些调色板同样可以被用来创建Colormap对象而不是颜色列表。
这些调色板同样可以被用来创建 Colormap 对象而不是颜色列表。
```py
pal = sns.dark_palette("palegreen", as_cmap=True)
......@@ -262,7 +262,7 @@ sns.kdeplot(x, y, cmap=pal);
![http://seaborn.pydata.org/_images/color_palettes_48_0.png](img/16096f5a5796354b892ba4f6ff2dcef1.jpg)
默认情况下,输入可以是任何有效的matplotlib颜色。替代解释由 `input` 参数控制。现在,您可以在 `hls``husl` 空间中提供元组以及默认的 `rgb`,您也可以使用任何有效的 `xkcd` 颜色来生成调色板。
默认情况下,输入可以是任何有效的 matplotlib 颜色。替代解释由 `input` 参数控制。现在,您可以在 `hls``husl` 空间中提供元组以及默认的 `rgb`,您也可以使用任何有效的 `xkcd` 颜色来生成调色板。
```py
sns.palplot(sns.light_palette((210, 90, 60), input="husl"))
......@@ -282,13 +282,13 @@ sns.palplot(sns.dark_palette("muted purple", input="xkcd"))
## 发散调色板
第三类调色板称为“发散调色板”(diverging)。当数据集的低值和高值都很重要,且数据集中有明确定义的中点时,这会是您的最佳选择。例如,绘制温度相对于基准时间点的变化图时,最好使用发散Colormap来同时显示温度相对于基准值的上升和下降
第三类调色板称为“发散调色板”(diverging)。当数据集的低值和高值都很重要,且数据集中有明确定义的中点时,这会是您的最佳选择。例如,绘制温度相对于基准时间点的变化图时,最好使用发散 Colormap 来同时显示温度相对于基准值的上升和下降
选择良好分散调色板的规则类似于良好的顺序调色板。不过在这种情况时需要注意两端颜色向中间颜色渐变时中间点的颜色不应该喧宾夺主,两端的颜色也应该具有相似的亮度和饱和度。
这里还需要强调的是,应该避免使用红色和绿色,因为需要考虑到[红绿色盲](https://en.wikipedia.org/wiki/Color_blindness)患者的观感。
不出所料,Color Brewer库也同样提供了一些精心挑选的发散调色板。
不出所料,Color Brewer 库也同样提供了一些精心挑选的发散调色板。
```py
......@@ -305,7 +305,7 @@ sns.palplot(sns.color_palette("RdBu_r", 7))
![http://seaborn.pydata.org/_images/color_palettes_55_0.png](img/a6f00f18e0a24fee984824847391d181.jpg)
matplotlib库中内置的 `coolwarm` 调色板也是一个很好的选择。请注意,这个Colormap的中间值和极值之间的对比度较小。
matplotlib 库中内置的 `coolwarm` 调色板也是一个很好的选择。请注意,这个 Colormap 的中间值和极值之间的对比度较小。
```py
sns.palplot(sns.color_palette("coolwarm", 7))
......@@ -316,7 +316,7 @@ sns.palplot(sns.color_palette("coolwarm", 7))
### 自定义发散调色板
您可以使用seaborn的[`diverging_palette()`](../generated/seaborn.diverging_palette.html#seaborn.diverging_palette "seaborn.diverging_palette")函数来创建自定义colormap来描述发散数据(搭配有交互式组件[`choose_diverging_palette()`](../generated/seaborn.choose_diverging_palette.html#seaborn.choose_diverging_palette "seaborn.choose_diverging_palette"))。此函数使用 `husl` 颜色系统来创建发散调色板,您需要在函数中设置两个色调参数(用度表示),也可以选择设置两端颜色的亮度和饱和度。 使用 `husl` 意味着两端到中间点的色调变化将是平衡的。
您可以使用 seaborn 的[`diverging_palette()`](../generated/seaborn.diverging_palette.html#seaborn.diverging_palette "seaborn.diverging_palette")函数来创建自定义 colormap 来描述发散数据(搭配有交互式组件[`choose_diverging_palette()`](../generated/seaborn.choose_diverging_palette.html#seaborn.choose_diverging_palette "seaborn.choose_diverging_palette"))。此函数使用 `husl` 颜色系统来创建发散调色板,您需要在函数中设置两个色调参数(用度表示),也可以选择设置两端颜色的亮度和饱和度。 使用 `husl` 意味着两端到中间点的色调变化将是平衡的。
```py
sns.palplot(sns.diverging_palette(220, 20, n=7))
......@@ -352,7 +352,7 @@ sns.palplot(sns.diverging_palette(255, 133, l=60, n=7, center="dark"))
## 设置默认调色板
[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数相伴随的有[`set_palette()`](../generated/seaborn.set_palette.html#seaborn.set_palette "seaborn.set_palette")。 两者之间的关系与[美学教程](aesthetics.html#aesthetics-tutorial)中介绍的[`set_palette()`](../generated/seaborn.set_palette.html#seaborn.set_palette "seaborn.set_palette")函数和[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数接受相同参数的关系相类似。但它会更改默认的matplotlib参数,以便调色板应用于所有图像。
[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数相伴随的有[`set_palette()`](../generated/seaborn.set_palette.html#seaborn.set_palette "seaborn.set_palette")。 两者之间的关系与[美学教程](aesthetics.html#aesthetics-tutorial)中介绍的[`set_palette()`](../generated/seaborn.set_palette.html#seaborn.set_palette "seaborn.set_palette")函数和[`color_palette()`](../generated/seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")函数接受相同参数的关系相类似。但它会更改默认的 matplotlib 参数,以便调色板应用于所有图像。
```py
def sinplot(flip=1):
......
docs/img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg

989 字节 | W: | H:

docs/img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg

855 字节 | W: | H:

docs/img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg
docs/img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg
docs/img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg
docs/img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/12d91b101a0391d48ce055f66e4a910a.jpg

814 字节 | W: | H:

docs/img/12d91b101a0391d48ce055f66e4a910a.jpg

740 字节 | W: | H:

docs/img/12d91b101a0391d48ce055f66e4a910a.jpg
docs/img/12d91b101a0391d48ce055f66e4a910a.jpg
docs/img/12d91b101a0391d48ce055f66e4a910a.jpg
docs/img/12d91b101a0391d48ce055f66e4a910a.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/13804c3cf58c9d108ea1d638b643451f.jpg

950 字节 | W: | H:

docs/img/13804c3cf58c9d108ea1d638b643451f.jpg

420 字节 | W: | H:

docs/img/13804c3cf58c9d108ea1d638b643451f.jpg
docs/img/13804c3cf58c9d108ea1d638b643451f.jpg
docs/img/13804c3cf58c9d108ea1d638b643451f.jpg
docs/img/13804c3cf58c9d108ea1d638b643451f.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/144ee4446ca7ff02dd03b831c6144dbb.jpg

951 字节 | W: | H:

docs/img/144ee4446ca7ff02dd03b831c6144dbb.jpg

391 字节 | W: | H:

docs/img/144ee4446ca7ff02dd03b831c6144dbb.jpg
docs/img/144ee4446ca7ff02dd03b831c6144dbb.jpg
docs/img/144ee4446ca7ff02dd03b831c6144dbb.jpg
docs/img/144ee4446ca7ff02dd03b831c6144dbb.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/151c643774e7ae51ed523abe3fa5f559.jpg

872 字节 | W: | H:

docs/img/151c643774e7ae51ed523abe3fa5f559.jpg

698 字节 | W: | H:

docs/img/151c643774e7ae51ed523abe3fa5f559.jpg
docs/img/151c643774e7ae51ed523abe3fa5f559.jpg
docs/img/151c643774e7ae51ed523abe3fa5f559.jpg
docs/img/151c643774e7ae51ed523abe3fa5f559.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/1b8a02d12771dd98fcd113bf3a601e27.jpg

929 字节 | W: | H:

docs/img/1b8a02d12771dd98fcd113bf3a601e27.jpg

511 字节 | W: | H:

docs/img/1b8a02d12771dd98fcd113bf3a601e27.jpg
docs/img/1b8a02d12771dd98fcd113bf3a601e27.jpg
docs/img/1b8a02d12771dd98fcd113bf3a601e27.jpg
docs/img/1b8a02d12771dd98fcd113bf3a601e27.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/2690d286a343ff53a43d15d54fc86e91.jpg

983 字节 | W: | H:

docs/img/2690d286a343ff53a43d15d54fc86e91.jpg

385 字节 | W: | H:

docs/img/2690d286a343ff53a43d15d54fc86e91.jpg
docs/img/2690d286a343ff53a43d15d54fc86e91.jpg
docs/img/2690d286a343ff53a43d15d54fc86e91.jpg
docs/img/2690d286a343ff53a43d15d54fc86e91.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/2d899c79eea5f0341a72b193b32ee84b.jpg

885 字节 | W: | H:

docs/img/2d899c79eea5f0341a72b193b32ee84b.jpg

515 字节 | W: | H:

docs/img/2d899c79eea5f0341a72b193b32ee84b.jpg
docs/img/2d899c79eea5f0341a72b193b32ee84b.jpg
docs/img/2d899c79eea5f0341a72b193b32ee84b.jpg
docs/img/2d899c79eea5f0341a72b193b32ee84b.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/429c1d877c3d7c4b23d82d35ade3603d.jpg

822 字节 | W: | H:

docs/img/429c1d877c3d7c4b23d82d35ade3603d.jpg

1015 字节 | W: | H:

docs/img/429c1d877c3d7c4b23d82d35ade3603d.jpg
docs/img/429c1d877c3d7c4b23d82d35ade3603d.jpg
docs/img/429c1d877c3d7c4b23d82d35ade3603d.jpg
docs/img/429c1d877c3d7c4b23d82d35ade3603d.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/6508f97c0a5563f99b755ccfac8c2b12.jpg

756 字节 | W: | H:

docs/img/6508f97c0a5563f99b755ccfac8c2b12.jpg

272 字节 | W: | H:

docs/img/6508f97c0a5563f99b755ccfac8c2b12.jpg
docs/img/6508f97c0a5563f99b755ccfac8c2b12.jpg
docs/img/6508f97c0a5563f99b755ccfac8c2b12.jpg
docs/img/6508f97c0a5563f99b755ccfac8c2b12.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/664ee3a6a4dfcace7697e385779f371b.jpg

944 字节 | W: | H:

docs/img/664ee3a6a4dfcace7697e385779f371b.jpg

396 字节 | W: | H:

docs/img/664ee3a6a4dfcace7697e385779f371b.jpg
docs/img/664ee3a6a4dfcace7697e385779f371b.jpg
docs/img/664ee3a6a4dfcace7697e385779f371b.jpg
docs/img/664ee3a6a4dfcace7697e385779f371b.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/6e3b5f94591e119cae1ead4b24d26c9e.jpg

950 字节 | W: | H:

docs/img/6e3b5f94591e119cae1ead4b24d26c9e.jpg

411 字节 | W: | H:

docs/img/6e3b5f94591e119cae1ead4b24d26c9e.jpg
docs/img/6e3b5f94591e119cae1ead4b24d26c9e.jpg
docs/img/6e3b5f94591e119cae1ead4b24d26c9e.jpg
docs/img/6e3b5f94591e119cae1ead4b24d26c9e.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/6e81b4c302189f59de63f96dbee3a197.jpg

949 字节 | W: | H:

docs/img/6e81b4c302189f59de63f96dbee3a197.jpg

329 字节 | W: | H:

docs/img/6e81b4c302189f59de63f96dbee3a197.jpg
docs/img/6e81b4c302189f59de63f96dbee3a197.jpg
docs/img/6e81b4c302189f59de63f96dbee3a197.jpg
docs/img/6e81b4c302189f59de63f96dbee3a197.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/75b405b71a445bc29d020b75ee4b3632.jpg

833 字节 | W: | H:

docs/img/75b405b71a445bc29d020b75ee4b3632.jpg

449 字节 | W: | H:

docs/img/75b405b71a445bc29d020b75ee4b3632.jpg
docs/img/75b405b71a445bc29d020b75ee4b3632.jpg
docs/img/75b405b71a445bc29d020b75ee4b3632.jpg
docs/img/75b405b71a445bc29d020b75ee4b3632.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/8d928f7a998a90772bc3defd036444a8.jpg

866 字节 | W: | H:

docs/img/8d928f7a998a90772bc3defd036444a8.jpg

802 字节 | W: | H:

docs/img/8d928f7a998a90772bc3defd036444a8.jpg
docs/img/8d928f7a998a90772bc3defd036444a8.jpg
docs/img/8d928f7a998a90772bc3defd036444a8.jpg
docs/img/8d928f7a998a90772bc3defd036444a8.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/a6f00f18e0a24fee984824847391d181.jpg

829 字节 | W: | H:

docs/img/a6f00f18e0a24fee984824847391d181.jpg

514 字节 | W: | H:

docs/img/a6f00f18e0a24fee984824847391d181.jpg
docs/img/a6f00f18e0a24fee984824847391d181.jpg
docs/img/a6f00f18e0a24fee984824847391d181.jpg
docs/img/a6f00f18e0a24fee984824847391d181.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/b0fa1a625cc563e5a13abc41fa080b59.jpg

820 字节 | W: | H:

docs/img/b0fa1a625cc563e5a13abc41fa080b59.jpg

745 字节 | W: | H:

docs/img/b0fa1a625cc563e5a13abc41fa080b59.jpg
docs/img/b0fa1a625cc563e5a13abc41fa080b59.jpg
docs/img/b0fa1a625cc563e5a13abc41fa080b59.jpg
docs/img/b0fa1a625cc563e5a13abc41fa080b59.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/b6ac2dda5753920442b42aa6c3f8746c.jpg

805 字节 | W: | H:

docs/img/b6ac2dda5753920442b42aa6c3f8746c.jpg

323 字节 | W: | H:

docs/img/b6ac2dda5753920442b42aa6c3f8746c.jpg
docs/img/b6ac2dda5753920442b42aa6c3f8746c.jpg
docs/img/b6ac2dda5753920442b42aa6c3f8746c.jpg
docs/img/b6ac2dda5753920442b42aa6c3f8746c.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/c32dd39f791f7d395dc47b37e1252b78.jpg

779 字节 | W: | H:

docs/img/c32dd39f791f7d395dc47b37e1252b78.jpg

683 字节 | W: | H:

docs/img/c32dd39f791f7d395dc47b37e1252b78.jpg
docs/img/c32dd39f791f7d395dc47b37e1252b78.jpg
docs/img/c32dd39f791f7d395dc47b37e1252b78.jpg
docs/img/c32dd39f791f7d395dc47b37e1252b78.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/c5d7ac6e8ae2f2ccf0f40dd4dccda398.jpg

783 字节 | W: | H:

docs/img/c5d7ac6e8ae2f2ccf0f40dd4dccda398.jpg

755 字节 | W: | H:

docs/img/c5d7ac6e8ae2f2ccf0f40dd4dccda398.jpg
docs/img/c5d7ac6e8ae2f2ccf0f40dd4dccda398.jpg
docs/img/c5d7ac6e8ae2f2ccf0f40dd4dccda398.jpg
docs/img/c5d7ac6e8ae2f2ccf0f40dd4dccda398.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/d07b38f860b0f58e365e7ea26da8be92.jpg

878 字节 | W: | H:

docs/img/d07b38f860b0f58e365e7ea26da8be92.jpg

1002 字节 | W: | H:

docs/img/d07b38f860b0f58e365e7ea26da8be92.jpg
docs/img/d07b38f860b0f58e365e7ea26da8be92.jpg
docs/img/d07b38f860b0f58e365e7ea26da8be92.jpg
docs/img/d07b38f860b0f58e365e7ea26da8be92.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/d206a78223b0280bfffbfd7cdb262145.jpg

939 字节 | W: | H:

docs/img/d206a78223b0280bfffbfd7cdb262145.jpg

888 字节 | W: | H:

docs/img/d206a78223b0280bfffbfd7cdb262145.jpg
docs/img/d206a78223b0280bfffbfd7cdb262145.jpg
docs/img/d206a78223b0280bfffbfd7cdb262145.jpg
docs/img/d206a78223b0280bfffbfd7cdb262145.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/dc21c66a962fb741f9f8f63c0374fae1.jpg

936 字节 | W: | H:

docs/img/dc21c66a962fb741f9f8f63c0374fae1.jpg

393 字节 | W: | H:

docs/img/dc21c66a962fb741f9f8f63c0374fae1.jpg
docs/img/dc21c66a962fb741f9f8f63c0374fae1.jpg
docs/img/dc21c66a962fb741f9f8f63c0374fae1.jpg
docs/img/dc21c66a962fb741f9f8f63c0374fae1.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/df43f6b2a11e5c0ee8c60f7ef2962e19.jpg

807 字节 | W: | H:

docs/img/df43f6b2a11e5c0ee8c60f7ef2962e19.jpg

772 字节 | W: | H:

docs/img/df43f6b2a11e5c0ee8c60f7ef2962e19.jpg
docs/img/df43f6b2a11e5c0ee8c60f7ef2962e19.jpg
docs/img/df43f6b2a11e5c0ee8c60f7ef2962e19.jpg
docs/img/df43f6b2a11e5c0ee8c60f7ef2962e19.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg

811 字节 | W: | H:

docs/img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg

269 字节 | W: | H:

docs/img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg
docs/img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg
docs/img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg
docs/img/e1506db895aa2aaa0d7df99cc7d3d4c3.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/e369a8cb7348d971f2471d297addf456.jpg

927 字节 | W: | H:

docs/img/e369a8cb7348d971f2471d297addf456.jpg

605 字节 | W: | H:

docs/img/e369a8cb7348d971f2471d297addf456.jpg
docs/img/e369a8cb7348d971f2471d297addf456.jpg
docs/img/e369a8cb7348d971f2471d297addf456.jpg
docs/img/e369a8cb7348d971f2471d297addf456.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/e558f322ef6826a8b67e10ff25919759.jpg

957 字节 | W: | H:

docs/img/e558f322ef6826a8b67e10ff25919759.jpg

408 字节 | W: | H:

docs/img/e558f322ef6826a8b67e10ff25919759.jpg
docs/img/e558f322ef6826a8b67e10ff25919759.jpg
docs/img/e558f322ef6826a8b67e10ff25919759.jpg
docs/img/e558f322ef6826a8b67e10ff25919759.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/eaa5d2a866409544e7f4f2f2b484e4f5.jpg

802 字节 | W: | H:

docs/img/eaa5d2a866409544e7f4f2f2b484e4f5.jpg

392 字节 | W: | H:

docs/img/eaa5d2a866409544e7f4f2f2b484e4f5.jpg
docs/img/eaa5d2a866409544e7f4f2f2b484e4f5.jpg
docs/img/eaa5d2a866409544e7f4f2f2b484e4f5.jpg
docs/img/eaa5d2a866409544e7f4f2f2b484e4f5.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/eac4541fd6a3e7b30eb535e0a1aab99f.jpg

939 字节 | W: | H:

docs/img/eac4541fd6a3e7b30eb535e0a1aab99f.jpg

965 字节 | W: | H:

docs/img/eac4541fd6a3e7b30eb535e0a1aab99f.jpg
docs/img/eac4541fd6a3e7b30eb535e0a1aab99f.jpg
docs/img/eac4541fd6a3e7b30eb535e0a1aab99f.jpg
docs/img/eac4541fd6a3e7b30eb535e0a1aab99f.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/f35d431e80f906b39aa82e1bd8390361.jpg

851 字节 | W: | H:

docs/img/f35d431e80f906b39aa82e1bd8390361.jpg

878 字节 | W: | H:

docs/img/f35d431e80f906b39aa82e1bd8390361.jpg
docs/img/f35d431e80f906b39aa82e1bd8390361.jpg
docs/img/f35d431e80f906b39aa82e1bd8390361.jpg
docs/img/f35d431e80f906b39aa82e1bd8390361.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/fb741f69016b77f7e6a93fc12ad8420c.jpg

828 字节 | W: | H:

docs/img/fb741f69016b77f7e6a93fc12ad8420c.jpg

484 字节 | W: | H:

docs/img/fb741f69016b77f7e6a93fc12ad8420c.jpg
docs/img/fb741f69016b77f7e6a93fc12ad8420c.jpg
docs/img/fb741f69016b77f7e6a93fc12ad8420c.jpg
docs/img/fb741f69016b77f7e6a93fc12ad8420c.jpg
  • 2-up
  • Swipe
  • Onion skin
docs/img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg

954 字节 | W: | H:

docs/img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg

360 字节 | W: | H:

docs/img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg
docs/img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg
docs/img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg
docs/img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册