提交 19519035 编写于 作者: W wizardforcel
# seaborn.relplot
> 译者:[Stuming](https://github.com/Stuming)
```py
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)
```
Figure-level interface for drawing relational plots onto a FacetGrid.
This function provides access to several different axes-level functions that show the relationship between two variables with semantic mappings of subsets. The `kind` parameter selects the underlying axes-level function to use:
绘制相关关系图像到FacetGrid的图像级别接口。
* [`scatterplot()`](seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot") (with `kind="scatter"`; the default)
* [`lineplot()`](seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot") (with `kind="line"`)
此函数提供对一些不同轴级别函数的访问,这些函数通过子集的语义映射显示两个变量之间的关系。`kind`参数选择要使用的基础轴级函数:
* [`scatterplot()`](seaborn.scatterplot.html#seaborn.scatterplot "seaborn.scatterplot") (通过`kind="scatter"`访问;默认为此)
* [`lineplot()`](seaborn.lineplot.html#seaborn.lineplot "seaborn.lineplot") (通过`kind="line"`访问)
Extra keyword arguments are passed to the underlying function, so you should refer to the documentation for each to see kind-specific options.
额外的关键字参数会被传递给隐含的函数,因此使用时应当参考对应函数的文档去了解各种选项。
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.
对于数据不同子集的`x``y`的绘制关系可以通过`hue`, `size`以及`style`参数控制。这些参数控制使用哪些视觉语义来区分不同的子集。使用所有三个语义类型可以独立展示三个维度,但是这种方式得到的绘制结果难以被理解而且低效。使用多种语义(例如对相同变量同时使用`hue``style`)可以使图像更加易懂。
See the [tutorial](../tutorial/relational.html#relational-tutorial) for more information.
参考[tutorial](../tutorial/relational.html#relational-tutorial)获得更多信息。
After plotting, the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") with the plot is returned and can be used directly to tweak supporting plot details or add other layers.
绘制后,会返回带有图像的[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"),随后可以直接进行图像细节调节或者加入其他图层。
Note that, unlike when using the underlying plotting functions directly, data must be passed in a long-form DataFrame with variables specified by passing strings to `x`, `y`, and other parameters.
值得注意的是,与直接使用隐含函数的方式不同,数据必须以长格式的DataFrame传入,同时变量通过`x`, `y`及其他参数指定。
参数:`x, y`names of variables in `data`
参数:`x, y``data`中的变量名
> Input data variables; must be numeric.
> 输入数据的变量;数据必须为数值型。
`hue`:name in `data`, optional
`hue`: `data`中的名称,可选
> Grouping variable that will produce elements with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
> 将会产生具有不同颜色的元素的变量进行分组。这些变量可以是类别变量或者数值型变量,尽管颜色映射在后面的情况中会有不同的表现。
`size`name in `data`, optional
`size``data`中的名称,可选
> Grouping variable that will produce elements with different sizes. Can be either categorical or numeric, although size mapping will behave differently in latter case.
> 将会产生具有不同尺寸的元素的变量进行分组。这些变量可以是类别变量或者数值型变量,尽管尺寸映射在后面的情况中会有不同的表现。
`style`name in `data`, optional
`style``data`中的名称,可选
> Grouping variable that will produce elements with different styles. Can have a numeric dtype but will always be treated as categorical.
> 将会产生具有不同风格的元素的变量进行分组。这些变量可以为数值型,但是通常会被当做类别变量处理。
`data`:DataFrame
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
> 长格式的DataFrame,每列是一个变量,每行是一个观察值。
`row, col`names of variables in `data`, optional
`row, col``data`中的变量名,可选
> Categorical variables that will determine the faceting of the grid.
> 确定网格的分面的类别变量。
`col_wrap`:int, optional
`col_wrap`:int, 可选
> “Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a `row` facet.
> 以此宽度“包裹”列变量,以便列分面跨越多行。与`row`分面不兼容。
`row_order, col_order`lists of strings, optional
`row_order, col_order`字符串列表,可选
> Order to organize the rows and/or columns of the grid in, otherwise the orders are inferred from the data objects.
> 以此顺序组织网格的行和/或列,否则顺序将从数据对象中推断。
`palette`palette name, list, or dict, optional
`palette`色盘名,列表,或者字典,可选
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
> 用于`hue`变量的不同级别的颜色。应当是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者将色调级别映射到matplotlib颜色的字典。
`hue_order`list, optional
`hue_order`列表,可选
> 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`变量层级出现的顺序,否则会根据数据确定。当`hue`变量为数值型时与此无关。
`hue_norm`tuple or Normalize object, optional
`hue_norm`元组或者Normalize对象,可选
> Normalization in data units for colormap applied to the `hue` variable when it is numeric. Not relevant if it is categorical.
> 当`hue`变量为数值型时,用于数据单元的colormap的标准化。如果`hue`为类别变量则与此无关。
`sizes`list, dict, or tuple, optional
`sizes`列表、典或者元组,可选
> 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.
> 当使用`sizes`时,用于确定如何选择尺寸。此变量可以一直是尺寸值的列表或者`size`变量的字典映射。当`size`为数值型时,此变量也可以是指定最小和最大尺寸的元组,这样可以将其他值标准化到这个范围。
`size_order`list, optional
`size_order`列表,可选
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
> 指定`size`变量层次的表现顺序,不指定则会通过数据确定。当`size`变量为数值型时与此无关。
`size_norm`tuple or Normalize object, optional
`size_norm`元组或者Normalize对象,可选
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
> 当`size`变量为数值型时,用于数据单元的scaling plot对象的标准化。
`legend`:“brief”, “full”, or False, optional
`legend`:“brief”, “full”, 或者False, 可选
> 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.
> 用于决定如何绘制坐标轴。如果参数值为“brief”, 数值型的`hue`以及`size`变量将会被用等间隔采样值表示。如果参数值为“full”, 每组都会在坐标轴中被记录。如果参数值为“false”, 不会添加坐标轴数据,也不会绘制坐标轴。
`kind`:string, optional
`kind`:string, 可选
> Kind of plot to draw, corresponding to a seaborn relational plot. Options are {`scatter` and `line`}.
> 绘制图的类型,与seaborn相关的图一致。可选项为(`scatter`及`line`).
`height`scalar, optional
`height`标量, 可选
> Height (in inches) of each facet. See also: `aspect`.
> 每个facet的高度(英寸)。参见`aspect`。
`aspect`scalar, optional
`aspect`标量, 可选
> Aspect ratio of each facet, so that `aspect * height` gives the width of each facet in inches.
> 每个facet的长宽比,因此“长宽比*高度”可以得出每个facet的宽度(英寸)。
`facet_kws`:dict, optional
`facet_kws`:dict, 可选
> Dictionary of other keyword arguments to pass to [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid").
> 以字典形式传给[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的其他关键字参数.
`kwargs`key, value pairings
`kwargs`键值对
> Other keyword arguments are passed through to the underlying plotting function.
> 传给后续绘制函数的其他关键字参数。
返回值:`g`[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")
> Returns the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") object with the plot on it for further tweaking.
> 返回包含图像的[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")对象,图像可以进一步调整。
Examples
示例
Draw a single facet to use the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") legend placement:
使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的坐标轴布局绘制简单的facet。
```py
>>> import seaborn as sns
......@@ -122,7 +123,7 @@ Draw a single facet to use the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.Face
![http://seaborn.pydata.org/_images/seaborn-relplot-1.png](img/1c7fa44b0679b71a3e8e8a4e26d75963.jpg)
Facet on the columns with another variable:
利用其他变量绘制facet:
```py
>>> g = sns.relplot(x="total_bill", y="tip",
......@@ -132,7 +133,7 @@ Facet on the columns with another variable:
![http://seaborn.pydata.org/_images/seaborn-relplot-2.png](img/f0eb2f840a13f8dbd2b829e6bb51c4af.jpg)
Facet on the columns and rows:
绘制两行两列的facet:
```py
>>> g = sns.relplot(x="total_bill", y="tip", hue="day",
......@@ -142,7 +143,7 @@ Facet on the columns and rows:
![http://seaborn.pydata.org/_images/seaborn-relplot-3.png](img/e6f2f0c866185be9801d43c59f348826.jpg)
“Wrap” many column facets into multiple rows:
将多行facets转换为多列:
```py
>>> g = sns.relplot(x="total_bill", y="tip", hue="time",
......@@ -152,7 +153,7 @@ Facet on the columns and rows:
![http://seaborn.pydata.org/_images/seaborn-relplot-4.png](img/a89db144a2f030e70603b92ba8728326.jpg)
Use multiple semantic variables on each facet with specified attributes:
利用指定的属性值对每个facet使用多种语义变量:
```py
>>> g = sns.relplot(x="total_bill", y="tip", hue="time", size="size",
......@@ -163,7 +164,7 @@ Use multiple semantic variables on each facet with specified attributes:
![http://seaborn.pydata.org/_images/seaborn-relplot-5.png](img/79d93fb6cd8974ec779ead1b35e2aad1.jpg)
Use a different kind of plot:
使用不同类型的图:
```py
>>> fmri = sns.load_dataset("fmri")
......@@ -175,7 +176,7 @@ Use a different kind of plot:
![http://seaborn.pydata.org/_images/seaborn-relplot-6.png](img/f14f4331afb42bd5512f2c24a5140604.jpg)
Change the size of each facet:
改变每个facet的大小:
```py
>>> g = sns.relplot(x="timepoint", y="signal",
......
......@@ -180,4 +180,4 @@ boxplot和核密度估计的结合。一个传统的箱型图具有类似的API
```
![http://seaborn.pydata.org/_images/seaborn-boxenplot-8.png](img/ef97d95b2084af9b8636c2514545289d.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-boxenplot-8.png](img/ef97d95b2084af9b8636c2514545289d.jpg)
......@@ -4,109 +4,108 @@
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)
```
Show point estimates and confidence intervals as rectangular bars.
条形图以矩形条的方式展示数据的点估值和置信区间
A bar plot represents an estimate of central tendency for a numeric variable with the height of each rectangle and provides some indication of the uncertainty around that estimate using error bars. Bar plots include 0 in the quantitative axis range, and they are a good choice when 0 is a meaningful value for the quantitative variable, and you want to make comparisons against it.
条形图用每个矩形的高度来表示数值变量的集中趋势的估计值,并提供误差条来显示估计值得不确定度。条形图的纵轴是从零开始的,这对于0值是有意义的情况是非常好的。
For datasets where 0 is not a meaningful value, a point plot will allow you to focus on differences between levels of one or more categorical variables.
对于数据集中的0值没有实际意义的情况,散点图可以让您专注于一个或多个分类变量之间的差异。
It is also important to keep in mind that a bar plot shows only the mean (or other estimator) value, but in many cases it may be more informative to show the distribution of values at each level of the categorical variables. In that case, other approaches such as a box or violin plot may be more appropriate.
要注意的是,条形图只显示平均值(或者其他的估计值),但是在大部分情况下,展示数值在不同分类变量上的分布会更有用。如果要表示出数据的分布,用箱型图或者小提琴图会更恰当。
Input data can be passed in a variety of formats, including:
输入数据的格式可以不同,包括:
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
* 以列表,numpy array或者pandas中的Series object 表示的向量。这些向量可以直接传入 `x`, `y`, 以及 `hue` 参数。
* 长表, x值,y值和色相变量决定了数据是如何绘制的。
* 宽表,每个列的数值都会被绘制出来.
* 数组或者列表的向量。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
大多数情况下,您可以使用numpy的对象或者python的对象,但是用pandas对象更好,因为相关的列名会被标注在图标上。 另外,为了控制绘图元素 您也可以可以用分类类型来组合不同的变量。
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
这个函数始终把一个变量当做分类变量,即使这个数据是数值类型或者日期类型,并且按照序数顺序绘制在相关的轴上。
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
详情请看[教程](../tutorial/categorical.html#categorical-tutorial)
参数:`x, y, hue`names of variables in `data` or vector data, optional
参数:`x, y, hue``data` 中的变量名词或者向量, optional
> Inputs for plotting long-form data. See examples for interpretation.
> 用于绘制long-form数据的变量名称.
`data`:DataFrame, array, or list of arrays, optional
`data`:DataFrame, 数组, 数组列表, optional
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
> 用于绘图的数据集。如果数据集有x和y,数据集会被认为是long-form,否则会被认为是wide-form。
`order, hue_order`lists of strings, optional
`order, hue_order`字符串列表, optional
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 绘制类别变量的顺序,如果没有,则从数据对象中推断绘图顺序。
`estimator`callable that maps vector -&gt; scalar, optional
`estimator`映射向量 -&gt; 标量, optional
> Statistical function to estimate within each categorical bin.
> 统计函数用于估计每个分类纸条中的值。.
`ci`:float or “sd” or None, optional
> Size of confidence intervals to draw around estimated values. If “sd”, skip bootstrapping and draw the standard deviation of the observations. If `None`, no bootstrapping will be performed, and error bars will not be drawn.
> 估计值周围的置信区间大小。如果输入的是 “sd”(标准差),会跳过bootstrapping的过程,只绘制数据的标准差。 如果输入是的是`None`, 不会执行botstrapping,而且错误条也不会绘制。
`n_boot`:int, optional
> Number of bootstrap iterations to use when computing confidence intervals.
> 计算置信区间需要的Boostrap迭代次数。
`units`:name of variable in `data` or vector data, optional
> Identifier of sampling units, which will be used to perform a multilevel bootstrap and account for repeated measures design.
> 采样单元的标识符,用于执行多级bootstrap并解释重复测量设计。
`orient`:“v” &#124; “h”, optional
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
> 绘图的方向(垂直或水平)。这通常是从输入变量的数据类型推断出来的,但是可以用来指定“分类”变量是数字还是宽格式数据。
`color`:matplotlib color, optional
> Color for all of the elements, or seed for a gradient palette.
> 作用于所有元素的颜色,或者渐变色的种子。
`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` 变量的颜色。 颜色要能被 [`color_palette()`]解释(seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 或者一个能映射到matplotlib颜色的字典。
`saturation`:float, optional
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
`errcolor`:matplotlib color
> Color for the lines that represent the confidence interval.
> 表示置信区间的线的颜色。
`errwidth`:float, optional
> Thickness of error bar lines (and caps).
> 误差条的线的厚度。
`capsize`:float, optional
> Width of the “caps” on error bars.
> 误差条端部的宽度。
`dodge`:bool, optional
**dodge** : 布尔型, optional
> When hue nesting is used, whether elements should be shifted along the categorical axis.
`ax`:matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
> 指定一个Axes用于绘图,如果不指定,则使用当前的Axes。
`kwargs`:key, value mappings
> Other keyword arguments are passed through to `plt.bar` at draw time.
> 其他的关键词参数在绘图时通过 `plt.bar` 传入。
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
> 返回有图表绘制的Axes对象。
See also
Show the counts of observations in each categorical bin.Show point estimates and confidence intervals using scatterplot glyphs.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
显示每个分类bin中的观察计数。使用散点图图示符显示点估计和置信区间。将分类图与类相结合:<cite>FacetGrid</cite>.
Examples
Draw a set of vertical bar plots grouped by a categorical variable:
绘制一组按类别变量分组的垂直条形图:
```py
>>> import seaborn as sns
......@@ -118,7 +117,7 @@ Draw a set of vertical bar plots grouped by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-barplot-1.png](img/9d1addc98b6a35ef0376219c56e7b7fd.jpg)
Draw a set of vertical bars with nested grouping by a two variables:
绘制一组由两个变量嵌套分组的垂直条形图:
```py
>>> ax = sns.barplot(x="day", y="total_bill", hue="sex", data=tips)
......@@ -127,7 +126,7 @@ Draw a set of vertical bars with nested grouping by a two variables:
![http://seaborn.pydata.org/_images/seaborn-barplot-2.png](img/863249efe2403afa4fae2f2b6884d3bd.jpg)
Draw a set of horizontal bars:
绘制一组水平条形图:
```py
>>> ax = sns.barplot(x="tip", y="day", data=tips)
......@@ -136,7 +135,7 @@ Draw a set of horizontal bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-3.png](img/c3ea6265eaff0a4bfaec2966088cb66f.jpg)
Control bar order by passing an explicit order:
通过传入一个显式的顺序来控制条柱的顺序:
```py
>>> ax = sns.barplot(x="time", y="tip", data=tips,
......@@ -146,7 +145,7 @@ Control bar order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-barplot-4.png](img/9233554272a5e436f6ab85c97a65010c.jpg)
Use median as the estimate of central tendency:
用中值来评估数据的集中趋势:
```py
>>> from numpy import median
......@@ -156,7 +155,7 @@ Use median as the estimate of central tendency:
![http://seaborn.pydata.org/_images/seaborn-barplot-5.png](img/2622373fb99932aa42e45c3b151135be.jpg)
Show the standard error of the mean with the error bars:
用误差条显示平均值的标准误差:
```py
>>> ax = sns.barplot(x="day", y="tip", data=tips, ci=68)
......@@ -165,7 +164,7 @@ Show the standard error of the mean with the error bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-6.png](img/d1310bd7e87a8549d1f0b3a1479fc06d.jpg)
Show standard deviation of observations instead of a confidence interval:
展示数据的标准差:
```py
>>> ax = sns.barplot(x="day", y="tip", data=tips, ci="sd")
......@@ -174,7 +173,7 @@ Show standard deviation of observations instead of a confidence interval:
![http://seaborn.pydata.org/_images/seaborn-barplot-7.png](img/eeb77dac6d8f76d9f715476ce03773c5.jpg)
Add “caps” to the error bars:
给误差条增加“端点”:
```py
>>> ax = sns.barplot(x="day", y="tip", data=tips, capsize=.2)
......@@ -183,7 +182,7 @@ Add “caps” to the error bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-8.png](img/5a69e1058d9b8b4b5be6dc15d1bad130.jpg)
Use a different color palette for the bars:
使用一个不同的调色盘来绘制图案:
```py
>>> ax = sns.barplot("size", y="total_bill", data=tips,
......@@ -193,7 +192,7 @@ Use a different color palette for the bars:
![http://seaborn.pydata.org/_images/seaborn-barplot-9.png](img/ef011fca38d3c55dde21ee8363e93e61.jpg)
Use `hue` without changing bar position or width:
在不改变条柱的位置或者宽度的前提下,使用 `hue` :
```py
>>> tips["weekend"] = tips["day"].isin(["Sat", "Sun"])
......@@ -204,7 +203,7 @@ Use `hue` without changing bar position or width:
![http://seaborn.pydata.org/_images/seaborn-barplot-10.png](img/d38d4ad12b16322a5ed00690bcbcd8b6.jpg)
Plot all bars in a single color:
用同一种颜色绘制所有条柱:
```py
>>> ax = sns.barplot("size", y="total_bill", data=tips,
......@@ -214,7 +213,7 @@ Plot all bars in a single color:
![http://seaborn.pydata.org/_images/seaborn-barplot-11.png](img/4922c693b75b7656b2f16f8fd2dd6509.jpg)
Use `plt.bar` keyword arguments to further change the aesthetic:
`plt.bar` 关键字参数进一步改变图表的样式:
```py
>>> ax = sns.barplot("day", "total_bill", data=tips,
......@@ -225,7 +224,7 @@ Use `plt.bar` keyword arguments to further change the aesthetic:
![http://seaborn.pydata.org/_images/seaborn-barplot-12.png](img/20114eb58ca40a3ccf0b20f14f426c83.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`barplot()`](#seaborn.barplot "seaborn.barplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 来结合 [`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",
......@@ -235,4 +234,4 @@ Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to com
```
![http://seaborn.pydata.org/_images/seaborn-barplot-13.png](img/a2d8b9c6867b1006b56e5508d5472c86.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-barplot-13.png](img/a2d8b9c6867b1006b56e5508d5472c86.jpg)
# seaborn.jointplot
> 译者:[Stuming](https://github.com/Stuming)
```py
seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, joint_kws=None, marginal_kws=None, annot_kws=None, **kwargs)
```
Draw a plot of two variables with bivariate and univariate graphs.
绘制两个变量的双变量及单变量图。
This function provides a convenient interface to the [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") class, with several canned plot kinds. This is intended to be a fairly lightweight wrapper; if you need more flexibility, you should use [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") directly.
这个函数提供调用[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")类的便捷接口,以及一些封装好的绘图类型。这是一个轻量级的封装,如果需要更多的灵活性,应当直接使用[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid").
参数:`x, y`:strings or vectors
参数:`x, y`:strings或者vectors
> Data or names of variables in `data`.
> `data`中的数据或者变量名。
`data`:DataFrame, optional
`data`:DataFrame, 可选
> DataFrame when `x` and `y` are variable names.
> 当`x`和`y`为变量名时的DataFrame.
`kind`:{ “scatter” &#124; “reg” &#124; “resid” &#124; “kde” &#124; “hex” }, optional
`kind`:{ “scatter” &#124; “reg” &#124; “resid” &#124; “kde” &#124; “hex” }, 可选
> Kind of plot to draw.
> 绘制图像的类型。
`stat_func`callable or None, optional
`stat_func`可调用的,或者None, 可选
> _Deprecated_
> 已过时
`color`:matplotlib color, optional
`color`:matplotlib颜色, 可选
> Color used for the plot elements.
> 用于绘制元素的颜色。
`height`:numeric, optional
`height`:numeric, 可选
> Size of the figure (it will be square).
> 图像的尺寸(方形)。
`ratio`:numeric, optional
`ratio`:numeric, 可选
> Ratio of joint axes height to marginal axes height.
> 中心轴的高度与侧边轴高度的比例
`space`:numeric, optional
`space`:numeric, 可选
> Space between the joint and marginal axes
> 中心和侧边轴的间隔大小
`dropna`:bool, optional
`dropna`:bool, 可选
> If True, remove observations that are missing from `x` and `y`.
> 如果为True, 移除`x`和`y`中的缺失值。
`{x, y}lim`:two-tuples, optional
`{x, y}lim`:two-tuples, 可选
> Axis limits to set before plotting.
> 绘制前设置轴的范围。
`{joint, marginal, annot}_kws`:dicts, optional
`{joint, marginal, annot}_kws`:dicts, 可选
> Additional keyword arguments for the plot components.
> 额外的关键字参数。
`kwargs`key, value pairings
`kwargs`键值对
> Additional keyword arguments are passed to the function used to draw the plot on the joint Axes, superseding items in the `joint_kws` dictionary.
> 额外的关键字参数会被传给绘制中心轴图像的函数,取代`joint_kws`字典中的项。
返回值:`grid`[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")
> [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") object with the plot on it.
> [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")对象.
See also
参考
The Grid class used for drawing this plot. Use it directly if you need more flexibility.
绘制图像的Grid类。如果需要更多的灵活性,可以直接使用Grid类。
Examples
示例
Draw a scatterplot with marginal histograms:
绘制带有侧边直方图的散点图:
```py
>>> import numpy as np, pandas as pd; np.random.seed(0)
......@@ -81,7 +83,7 @@ Draw a scatterplot with marginal histograms:
![http://seaborn.pydata.org/_images/seaborn-jointplot-1.png](img/48d5020fcbaa6d2f36aae520f84a6234.jpg)
Add regression and kernel density fits:
添加回归线及核密度拟合:
```py
>>> g = sns.jointplot("total_bill", "tip", data=tips, kind="reg")
......@@ -90,7 +92,7 @@ Add regression and kernel density fits:
![http://seaborn.pydata.org/_images/seaborn-jointplot-2.png](img/8434c101b75c73a9e1b8dfb89975a2b5.jpg)
Replace the scatterplot with a joint histogram using hexagonal bins:
将散点图替换为六角形箱体图:
```py
>>> g = sns.jointplot("total_bill", "tip", data=tips, kind="hex")
......@@ -99,7 +101,7 @@ Replace the scatterplot with a joint histogram using hexagonal bins:
![http://seaborn.pydata.org/_images/seaborn-jointplot-3.png](img/6d5c569bf97b1f683a2ec921e1031112.jpg)
Replace the scatterplots and histograms with density estimates and align the marginal Axes tightly with the joint Axes:
将散点图和直方图替换为密度估计,并且将侧边轴与中心轴对齐:
```py
>>> iris = sns.load_dataset("iris")
......@@ -110,7 +112,7 @@ Replace the scatterplots and histograms with density estimates and align the mar
![http://seaborn.pydata.org/_images/seaborn-jointplot-4.png](img/c2c70e8889861b837b4fd45d707a6616.jpg)
Draw a scatterplot, then add a joint density estimate:
绘制散点图,添加中心密度估计:
```py
>>> g = (sns.jointplot("sepal_length", "sepal_width",
......@@ -121,7 +123,7 @@ Draw a scatterplot, then add a joint density estimate:
![http://seaborn.pydata.org/_images/seaborn-jointplot-5.png](img/b6895c87c4fa5a7fa1dc151dc3e5b385.jpg)
Pass vectors in directly without using Pandas, then name the axes:
不适用Pandas, 直接传输向量,随后给轴命名:
```py
>>> x, y = np.random.randn(2, 300)
......@@ -132,7 +134,7 @@ Pass vectors in directly without using Pandas, then name the axes:
![http://seaborn.pydata.org/_images/seaborn-jointplot-6.png](img/72b1f526c884ba4a6a285f1e8723013e.jpg)
Draw a smaller figure with more space devoted to the marginal plots:
绘制侧边图空间更大的图像:
```py
>>> g = sns.jointplot("total_bill", "tip", data=tips,
......@@ -142,7 +144,7 @@ Draw a smaller figure with more space devoted to the marginal plots:
![http://seaborn.pydata.org/_images/seaborn-jointplot-7.png](img/ddcf0a83320e56c75f2d5d15ff29c874.jpg)
Pass keyword arguments down to the underlying plots:
传递关键字参数给后续绘制函数:
```py
>>> g = sns.jointplot("petal_length", "sepal_length", data=iris,
......
......@@ -4,73 +4,73 @@
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)
```
Subplot grid for plotting pairwise relationships in a dataset.
用于绘制数据集中成对关系的子图网格。
This class maps each variable in a dataset onto a column and row in a grid of multiple axes. Different axes-level plotting functions can be used to draw bivariate plots in the upper and lower triangles, and the the marginal distribution of each variable can be shown on the diagonal.
此类将数据集中的每个变量映射到多个轴的网格中的列和行。可以使用不同的轴级绘图函数来绘制上三角和下三角的双变量图,并且对角线上可以显示每个变量的边际分布。
It can also represent an additional level of conditionalization with the `hue` parameter, which plots different subets of data in different colors. This uses color to resolve elements on a third dimension, but only draws subsets on top of each other and will not tailor the `hue` parameter for the specific visualization the way that axes-level functions that accept `hue` will.
它还可以通过`hue`参数用不同颜色绘制不同的数据子集来表示附加级别的条件化。这使用颜色来解析第三维的元素,但只是在彼此之上绘制子集,并且不会像接受`hue`的轴级函数那样为特定可视化定制`hue`参数。
See the [tutorial](../tutorial/axis_grids.html#grid-tutorial) for more information.
参考[教程](../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)
```
Initialize the plot figure and PairGrid object.
初始化绘图和PairGrid对象。
参数:`data`:DataFrame
参数:`data`:DataFrame格式
> Tidy (long-form) dataframe where each column is a variable and each row is an observation.
> 整洁(长形式)数据框,其中每列是一个变量,每行是一个观察。
`hue`string (variable name), optional
`hue`字符串 (变量名), 可选
> Variable in `data` to map plot aspects to different colors.
> `data`中的变量,将绘图的不同面映射为不同的颜色。
`hue_order`list of strings
`hue_order`字符串列表
> Order for the levels of the hue variable in the palette
> 调色板中色调变量的等级顺序
`palette`dict or seaborn color palette
`palette`字典或者seaborn调色板
> Set of colors for mapping the `hue` variable. If a dict, keys should be values in the `hue` variable.
> 用于映射`hue`变量的颜色集.如果是一个字典,键应为`hue`变量中的值。
`hue_kws`dictionary of param -&gt; list of values mapping
`hue_kws`参数字典 -&gt; 值列表映射
> Other keyword arguments to insert into the plotting call to let other plot attributes vary across levels of the hue variable (e.g. the markers in a scatterplot).
> 其它的关键字参数,通过插入到绘图调用中使得其它的绘图属性在色调变量的不同水平上变化(例如散点图中的标记)。
`vars`list of variable names, optional
`vars`变量名列表, 可选
> Variables within `data` to use, otherwise use every column with a numeric datatype.
> 使用`data`中的变量,否则使用一个数值型数据类型的每一列。
`{x, y}_vars`lists of variable names, optional
`{x, y}_vars`变量名列表,可选
> Variables within `data` to use separately for the rows and columns of the figure; i.e. to make a non-square plot.
> 将`data`中的变量分别用于图的行和列,即制作非方形图。
`height`scalar, optional
`height`标量,可选
> Height (in inches) of each facet.
> 每个刻面的高度(以英寸为单位)。
`aspect`scalar, optional
`aspect`标量,可选
> Aspect * height gives the width (in inches) of each facet.
> aspect和height的乘积得出每个刻面的宽度(以英寸为单位)。
`despine`boolean, optional
`despine`布尔值,可选
> Remove the top and right spines from the plots.
> 从图中移除顶部和右侧脊柱。
`dropna`boolean, optional
`dropna`布尔值,可选
> Drop missing values from the data before plotting.
> 在绘图之前删除数据中的缺失值。
See also
另见
Easily drawing common uses of [`PairGrid`](#seaborn.PairGrid "seaborn.PairGrid").Subplot grid for plotting conditional relationships.
轻松绘制[`PairGrid`](#seaborn.PairGrid "seaborn.PairGrid")的常用用法。用于绘制条件关系的子图网格。
Examples
例子
Draw a scatterplot for each pairwise relationship:
为每个成对关系绘制一个散点图:
```py
>>> import matplotlib.pyplot as plt
......@@ -83,7 +83,7 @@ Draw a scatterplot for each pairwise relationship:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-1.png](img/34fc6de3cfc117757cc0e5f658a06928.jpg)
Show a univariate distribution on the diagonal:
在对角线上显示单变量分布:
```py
>>> g = sns.PairGrid(iris)
......@@ -94,9 +94,9 @@ Show a univariate distribution on the diagonal:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-2.png](img/7e2b84efc57efecba1f8c1bfad570874.jpg)
(It’s not actually necessary to catch the return value every time, as it is the same object, but it makes it easier to deal with the doctests).
(实际上没有必要每次都获取返回值,因为它是同一个对象,但它使得更容易处理文档测试)。
Color the points using a categorical variable:
使用分类变量对点进行着色:
```py
>>> g = sns.PairGrid(iris, hue="species")
......@@ -108,7 +108,7 @@ Color the points using a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-3.png](img/6df84055fcde05fec3e0b9794967ad71.jpg)
Use a different style to show multiple histograms:
使用不同的样式显示多个直方图:
```py
>>> g = sns.PairGrid(iris, hue="species")
......@@ -120,7 +120,7 @@ Use a different style to show multiple histograms:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-4.png](img/b269cdc188b02e86196c919d1bd87402.jpg)
Plot a subset of variables
绘制变量的子集
```py
>>> g = sns.PairGrid(iris, vars=["sepal_length", "sepal_width"])
......@@ -130,7 +130,7 @@ Plot a subset of variables
![http://seaborn.pydata.org/_images/seaborn-PairGrid-5.png](img/81ab9afd2faa6448de3c2b5a73ea3320.jpg)
Pass additional keyword arguments to the functions
将其它关键字参数传给函数。
```py
>>> g = sns.PairGrid(iris)
......@@ -141,7 +141,7 @@ Pass additional keyword arguments to the functions
![http://seaborn.pydata.org/_images/seaborn-PairGrid-6.png](img/ff58dc3588f11a9e3f9291926a0c86ff.jpg)
Use different variables for the rows and columns:
对行和列使用不同的变量:
```py
>>> g = sns.PairGrid(iris,
......@@ -153,7 +153,7 @@ Use different variables for the rows and columns:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-7.png](img/0d8364e9bb731fa5d89b998087ba0635.jpg)
Use different functions on the upper and lower triangles:
在上三角和下三角使用不同的函数:
```py
>>> g = sns.PairGrid(iris)
......@@ -165,7 +165,7 @@ Use different functions on the upper and lower triangles:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-8.png](img/58e8af844e6f097dc5995d7a2be70b0e.jpg)
Use different colors and markers for each categorical level:
为每个分类级别使用不同的颜色和标记:
```py
>>> g = sns.PairGrid(iris, hue="species", palette="Set2",
......@@ -177,14 +177,14 @@ Use different colors and markers for each categorical level:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-9.png](img/c9a2068151affcefc99a7b280ab0a52b.jpg)
Methods
| [`__init__`](#seaborn.PairGrid.__init__ "seaborn.PairGrid.__init__")(data[, hue, hue_order, palette, …]) | Initialize the plot figure and PairGrid object. |
| `add_legend`([legend_data, title, label_order]) | Draw a legend, maybe placing it outside axes and resizing the figure. |
| [`map`](seaborn.PairGrid.map.html#seaborn.PairGrid.map "seaborn.PairGrid.map")(func, **kwargs) | Plot with the same function in every subplot. |
| [`map_diag`](seaborn.PairGrid.map_diag.html#seaborn.PairGrid.map_diag "seaborn.PairGrid.map_diag")(func, **kwargs) | Plot with a univariate function on each diagonal subplot. |
| [`map_lower`](seaborn.PairGrid.map_lower.html#seaborn.PairGrid.map_lower "seaborn.PairGrid.map_lower")(func, **kwargs) | Plot with a bivariate function on the lower diagonal subplots. |
| [`map_offdiag`](seaborn.PairGrid.map_offdiag.html#seaborn.PairGrid.map_offdiag "seaborn.PairGrid.map_offdiag")(func, **kwargs) | Plot with a bivariate function on the off-diagonal subplots. |
| [`map_upper`](seaborn.PairGrid.map_upper.html#seaborn.PairGrid.map_upper "seaborn.PairGrid.map_upper")(func, **kwargs) | Plot with a bivariate function on the upper diagonal subplots. |
| `savefig`(*args, **kwargs) | Save the figure. |
| `set`(**kwargs) | Set attributes on each subplot Axes. |
\ No newline at end of file
方法
| [`__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) | 在每个对角线子图上用一个单变量函数绘制。 |
| [`map_lower`](seaborn.PairGrid.map_lower.html#seaborn.PairGrid.map_lower "seaborn.PairGrid.map_lower")(func, **kwargs) | 在下三角子图上用一个双变量函数绘制。|
| [`map_offdiag`](seaborn.PairGrid.map_offdiag.html#seaborn.PairGrid.map_offdiag "seaborn.PairGrid.map_offdiag")(func, **kwargs) | 在非对角线子图上用一个双变量函数绘制。 |
| [`map_upper`](seaborn.PairGrid.map_upper.html#seaborn.PairGrid.map_upper "seaborn.PairGrid.map_upper")(func, **kwargs) | 在上三角子图上用一个双变量函数绘制。|
| `savefig`(*args, **kwargs) | 保存图。 |
| `set`(**kwargs) | 在每个子图轴上设置属性。 |
......@@ -4,9 +4,9 @@
PairGrid.map(func, **kwargs)
```
Plot with the same function in every subplot.
在每个子图中用相同的函数绘制。
参数:`func`callable plotting function
参数:`func`可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为`color`和`label`的kwargs。
......@@ -4,9 +4,9 @@
PairGrid.map_diag(func, **kwargs)
```
Plot with a univariate function on each diagonal subplot.
在每一个对角线子图上用一个单变量函数绘制。
参数:`func`callable plotting function
参数:`func`可调用的绘图函数
> Must take an x array as a positional argument and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
>必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
......@@ -4,9 +4,9 @@
PairGrid.map_offdiag(func, **kwargs)
```
Plot with a bivariate function on the off-diagonal subplots.
在非对角线子图上用一个双变量函数绘图。
参数:`func`callable plotting function
参数:`func`可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
......@@ -4,9 +4,9 @@
PairGrid.map_lower(func, **kwargs)
```
Plot with a bivariate function on the lower diagonal subplots.
在下对角线子图上用一个双变量函数绘图。
参数:`func`callable plotting function
参数:`func`可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为`color`和`label`的kwargs。
......@@ -4,9 +4,9 @@
PairGrid.map_upper(func, **kwargs)
```
Plot with a bivariate function on the upper diagonal subplots.
在上对角线子图上用一个双变量函数绘图。
参数:`func`callable plotting function
参数:`func`可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
......@@ -4,51 +4,49 @@
class seaborn.JointGrid(x, y, data=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, size=None)
```
Grid for drawing a bivariate plot with marginal univariate plots.
用于绘制具有边际单变量图的双变量图的网格。
```py
__init__(x, y, data=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, size=None)
```
Set up the grid of subplots.
设置子图的网格。
参数:`x, y`strings or vectors
参数:`x, y`字符串或向量
> Data or names of variables in `data`.
> 在 `data`中的数据或变量名
`data`:DataFrame, optional
`data`:DataFrame, 可选
> DataFrame when `x` and `y` are variable names.
> 当 `x` and `y` 是变量名的时候为DataFrame。
`height`numeric
`height`数字
> Size of each side of the figure in inches (it will be square).
> 图中每一条边的大小(以英寸为单位)
`ratio`numeric
`ratio`数字
> Ratio of joint axes size to marginal axes height.
> 联合轴大小与边缘轴高度的比率。
`space`numeric, optional
`space`数字,可选
> Space between the joint and marginal axes
> 联合轴和边缘轴之间的空间
`dropna`:bool, optional
`dropna`:bool, 可选
> If True, remove observations that are missing from &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt;.
> 如果为True,则删除 &lt;cite&gt;x&lt;/cite&gt; 和 &lt;cite&gt;y&lt;/cite&gt;中缺少的观察结果。
`{x, y}lim`two-tuples, optional
`{x, y}lim`二元组,可选
> Axis limits to set before plotting.
> 在绘图之前设置轴限制。
也可以看看
用于绘制具有多种不同默认绘图类型的双变量图的高级界面。
See also
例子:
High-level interface for drawing bivariate plots with several different default plot kinds.
Examples
Initialize the figure but don’t draw any plots onto it:
初始化图形,但不在其上绘制任何图形:
```py
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
......@@ -59,7 +57,7 @@ Initialize the figure but don’t draw any plots onto it:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-1.png](img/a0e79dac9add2a97da1c95241a6122ab.jpg)
Add plots using default parameters:
使用默认参数添加绘图:
```py
>>> g = sns.JointGrid(x="total_bill", y="tip", data=tips)
......@@ -69,7 +67,7 @@ Add plots using default parameters:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-2.png](img/f984c858bd63441ea9761d632cb76d2c.jpg)
Draw the join and marginal plots separately, which allows finer-level control other parameters:
分别绘制联合分布图和边缘直方图,这可以以更精细的级别控制其他参数:
```py
>>> import matplotlib.pyplot as plt
......@@ -81,7 +79,7 @@ Draw the join and marginal plots separately, which allows finer-level control ot
![http://seaborn.pydata.org/_images/seaborn-JointGrid-3.png](img/3e159b4a38edb79ede76d93a55e2acb9.jpg)
Draw the two marginal plots separately:
分别绘制两个边缘直方图:
```py
>>> import numpy as np
......@@ -97,7 +95,7 @@ Draw the two marginal plots separately:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-4.png](img/1db698012d05626321ac93ffb7668a2c.jpg)
Add an annotation with a statistic summarizing the bivariate relationship:
添加注释,其中包含总结双变量关系的统计信息:
```py
>>> from scipy import stats
......@@ -111,7 +109,7 @@ Add an annotation with a statistic summarizing the bivariate relationship:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-5.png](img/fa99a0a13450712a4f2b13d983b1e766.jpg)
Use a custom function and formatting for the annotation
使用自定义的函数和注释格式
```py
>>> g = sns.JointGrid(x="total_bill", y="tip", data=tips)
......@@ -126,7 +124,7 @@ Use a custom function and formatting for the annotation
![http://seaborn.pydata.org/_images/seaborn-JointGrid-6.png](img/a8307f7ba7809b63c523168fde9e9379.jpg)
Remove the space between the joint and marginal axes:
移除联合轴和边缘轴之间的空间:
```py
>>> g = sns.JointGrid(x="total_bill", y="tip", data=tips, space=0)
......@@ -137,7 +135,7 @@ Remove the space between the joint and marginal axes:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-7.png](img/5beaabfceb79e2eef9563fc3044dd5f6.jpg)
Draw a smaller plot with relatively larger marginal axes:
绘制具有相对较大边缘轴的较小图:
```py
>>> g = sns.JointGrid(x="total_bill", y="tip", data=tips,
......@@ -149,7 +147,7 @@ Draw a smaller plot with relatively larger marginal axes:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-8.png](img/bfc4c60af4e09992569375d51943de88.jpg)
Set limits on the axes:
设置轴的限制:
```py
>>> g = sns.JointGrid(x="total_bill", y="tip", data=tips,
......@@ -161,12 +159,18 @@ Set limits on the axes:
![http://seaborn.pydata.org/_images/seaborn-JointGrid-9.png](img/3a85305cd59104b4d9403deb570373cc.jpg)
Methods
方法
[`__init__`](#seaborn.JointGrid.__init__ "seaborn.JointGrid.__init__")(x, y[, data, height, ratio, space, …]) | 设置子图的网格设置子图的网格。
`annotate`(func[, template, stat, loc]) | 用关于关系的统计数据来标注绘图。
[`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_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; 的单变量图。
`savefig`(*args, **kwargs) | 封装 figure.savefig 默认为紧边界框。
| [`__init__`](#seaborn.JointGrid.__init__ "seaborn.JointGrid.__init__")(x, y[, data, height, ratio, space, …]) | Set up the grid of subplots. |
| `annotate`(func[, template, stat, loc]) | Annotate the plot with a statistic about the relationship. |
| [`plot`](seaborn.JointGrid.plot.html#seaborn.JointGrid.plot "seaborn.JointGrid.plot")(joint_func, marginal_func[, annot_func]) | Shortcut to draw the full plot. |
| [`plot_joint`](seaborn.JointGrid.plot_joint.html#seaborn.JointGrid.plot_joint "seaborn.JointGrid.plot_joint")(func, **kwargs) | Draw a bivariate plot of &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt;. |
| [`plot_marginals`](seaborn.JointGrid.plot_marginals.html#seaborn.JointGrid.plot_marginals "seaborn.JointGrid.plot_marginals")(func, **kwargs) | Draw univariate plots for &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt; separately. |
| `savefig`(*args, **kwargs) | Wrap figure.savefig defaulting to tight bounding box. |
| `set_axis_labels`([xlabel, ylabel]) | Set the axis labels on the bivariate axes. |
\ No newline at end of file
`set_axis_labels`([xlabel, ylabel]) |在双变量轴上设置轴标签。
......@@ -4,16 +4,14 @@
JointGrid.plot(joint_func, marginal_func, annot_func=None)
```
Shortcut to draw the full plot.
绘制完整绘图的快捷方式。
Use &lt;cite&gt;plot_joint&lt;/cite&gt; and &lt;cite&gt;plot_marginals&lt;/cite&gt; directly for more control.
直接使用 &lt;cite&gt;plot_joint&lt;/cite&gt;&lt;cite&gt;plot_marginals&lt;/cite&gt; 进行更多控制.
参数:**joint_func, marginal_func:callables**
参数:**joint_func, marginal_func:可调用**
> Functions to draw the bivariate and univariate plots.
> 绘制双变量和单变量图的函数。
返回值:`self`:JointGrid 实例
返回值:`self`:JointGrid instance
> Returns &lt;cite&gt;self&lt;/cite&gt;.
> 返回 &lt;cite&gt;self&lt;/cite&gt;.
......@@ -4,18 +4,16 @@
JointGrid.plot_joint(func, **kwargs)
```
Draw a bivariate plot of &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt;.
绘制 &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt;的双变量图。
参数:`func`plotting callable
参数:`func`可调用的绘图函数
> This must take two 1d arrays of data as the first two positional arguments, and it must plot on the “current” axes.
> 这必须将两个一维数据数组作为前两个位置参数,并且必须在“当前”轴上绘制。
`kwargs`key, value mappings
`kwargs`键,值映射
> Keyword argument are passed to the plotting function.
> 关键字参数传递给绘图函数。
返回值:`self`:JointGrid 实例
返回值:`self`:JointGrid instance
> Returns &lt;cite&gt;self&lt;/cite&gt;.
> 返回 &lt;cite&gt;self&lt;/cite&gt;.
......@@ -4,18 +4,16 @@
JointGrid.plot_marginals(func, **kwargs)
```
Draw univariate plots for &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt; separately.
分别绘制 &lt;cite&gt;x&lt;/cite&gt;&lt;cite&gt;y&lt;/cite&gt; 的单变量图。
参数:`func`plotting callable
参数:`func`可调用的绘图函数
> This must take a 1d array of data as the first positional argument, it must plot on the “current” axes, and it must accept a “vertical” keyword argument to orient the measure dimension of the plot vertically.
> 这必须将一维数据数组作为第一个位置参数,它必须在“当前”轴上绘图,并且它必须接受“垂直”关键字参数以垂直定向图的度量维度。
`kwargs`key, value mappings
`kwargs`键,值映射
> Keyword argument are passed to the plotting function.
> 关键字参数传递给绘图函数。
返回值:`self`:JointGrid 实例
返回值:`self`:JointGrid instance
> Returns &lt;cite&gt;self&lt;/cite&gt;.
> 返回 &lt;cite&gt;self&lt;/cite&gt;.
# seaborn.plotting_context
```py
```python
seaborn.plotting_context(context=None, font_scale=1, rc=None)
```
以dict形式返回参数,用以缩放图形的元素。
Return a parameter dict to scale elements of the figure.
This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. The base context is “notebook”, and the other contexts are “paper”, “talk”, and “poster”, which are version of the notebook parameters scaled by .8, 1.3, and 1.6, respectively.
This function returns an object that can be used in a `with` statement to temporarily change the context parameters.
参数:`context`:dict, None, or one of {paper, notebook, talk, poster}
这些参数可以影响诸如标签大小,线条和绘图的其他元素,但不会影响整体样式。基础文本时"notebook",和其他文本"paper","talk"和"poster",它们分别是0.8,1.3和1.6的notebook参数版本。
> A dictionary of parameters or the name of a preconfigured set.
该函数返回一个对象,该对象可以在`with`语句中使用,临时改变文本参数。
`font_scale`:float, optional
参数:`context`:dict, None 或者是{paper, notebook, talk, poster}其中一个
> Separate scaling factor to independently scale the size of the font elements.
> 参数集或者是预设集合的名字
`rc`:dict, optional
`font_scale`:浮点数,可选
> Parameter mappings to override the values in the preset seaborn context dictionaries. This only updates parameters that are considered part of the context definition.
> 单独的缩放因子可以独立缩放字体元素大小
`rc`:dict,可选
> 参数映射以覆盖预设的seaborn的文本字典中的值。这只更新被视为文本定义的一部分的参数。
See also
也可参见
set the matplotlib parameters to scale plot elementsreturn a dict of parameters defining a figure styledefine the color palette for a plot
设置matplotlib参数以调整绘图元素返回定义图形样式的参数的dict,定义绘图的调色板。
Examples
示例:
```py
```python
>>> c = plotting_context("poster")
```
```py
```python
>>> c = plotting_context("notebook", font_scale=1.5)
```
```py
```python
>>> c = plotting_context("talk", rc={"lines.linewidth": 2})
```
```py
```python
>>> import matplotlib.pyplot as plt
>>> with plotting_context("paper"):
... f, ax = plt.subplots()
... ax.plot(x, y)
... f, ax = plt.subplots()
... ax.plot(x, y)
```
```
\ No newline at end of file
# seaborn.set_context
```py
seaborn.set_context(context=None, font_scale=1, rc=None)
```
Set the plotting context parameters.
This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. The base context is “notebook”, and the other contexts are “paper”, “talk”, and “poster”, which are version of the notebook parameters scaled by .8, 1.3, and 1.6, respectively.
参数:`context`:dict, None, or one of {paper, notebook, talk, poster}
> A dictionary of parameters or the name of a preconfigured set.
`font_scale`:float, optional
> Separate scaling factor to independently scale the size of the font elements.
`rc`:dict, optional
> Parameter mappings to override the values in the preset seaborn context dictionaries. This only updates parameters that are considered part of the context definition.
See also
return a dictionary of rc parameters, or use in a `with` statement to temporarily set the context.set the default parameters for figure styleset the default color palette for figures
Examples
```py
>>> set_context("paper")
```
```py
>>> set_context("talk", font_scale=1.4)
```
```py
>>> set_context("talk", rc={"lines.linewidth": 2})
```
\ No newline at end of file
# seaborn.set_context
```python
seaborn.set_context(context=None, font_scale=1, rc=None)
```
设置绘图文本参数。
这些参数可以影响诸如标签大小,线条和绘图的其他元素,但不会影响整体样式。基础文本时"notebook",和其他文本"paper","talk"和"poster",它们分别是0.8,1.3和1.6的notebook参数版本。
参数:`context`:dict, None 或者是{paper, notebook, talk, poster}其中一个
> 参数集或者是预设集合的名字
`font_scale`:浮点数,可选
> 单独的缩放因子可以独立缩放字体元素大小
`rc`:dict,可选
> 参数映射以覆盖预设的seaborn的上下文字典中的值。这只更新被视为上下文定义的一部分的参数。
也可参见
返回一个rc参数的字典,或者在`with`语句中使用临时设置context.set图样式的默认为数字的默认调色板
示例
```python
>>> set_context("paper")
```
```python
>>> set_context("talk", font_scale=1.4)
```
```python
>>> set_context("talk", rc={"lines.linewidth": 2})
```
# seaborn.set_color_codes
```py
seaborn.set_color_codes(palette='deep')
```
Change how matplotlib color shorthands are interpreted.
Calling this will change how shorthand codes like “b” or “g” are interpreted by matplotlib in subsequent plots.
参数:`palette`:{deep, muted, pastel, dark, bright, colorblind}
> Named seaborn palette to use as the source of colors.
See also
Color codes can be set through the high-level seaborn style manager.Color codes can also be set through the function that sets the matplotlib color cycle.
Examples
Map matplotlib color codes to the default seaborn palette.
```py
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns; sns.set()
>>> sns.set_color_codes()
>>> _ = plt.plot([0, 1], color="r")
```
![http://seaborn.pydata.org/_images/seaborn-set_color_codes-1.png](img/f7331a33eaedf9eae59191642f7a64e4.jpg)
Use a different seaborn palette.
```py
>>> sns.set_color_codes("dark")
>>> _ = plt.plot([0, 1], color="g")
>>> _ = plt.plot([0, 2], color="m")
```
![http://seaborn.pydata.org/_images/seaborn-set_color_codes-2.png](img/35544ecf6de962c91ab860527035f39f.jpg)
\ No newline at end of file
# seaborn.set_color_codes
```python
seaborn.set_color_codes(palette='deep')
```
改变matplotlib颜色缩写词的解释方式。
调用此方法将改变matplotlib在后续图表中解释缩写词,例如"b"或"g"的方式。
参数: `palette`: {deep, muted, pastel, dark, bright, colorblind}
> 预命名的seaborn调色板,用作颜色的来源
参见
可以通过高级seaborn样式管理器设置颜色代码。也可以通过设置matplotlib颜色循环功能设置颜色代码。
示例:
将matplotlib颜色代码映射到默认的seaborn调色板。
```python
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns; sns.set()
>>> sns.set_color_codes()
>>> _ = plt.plot([0, 1], color="r")
```
![http://seaborn.pydata.org/_images/seaborn-set_color_codes-1.png](img/f7331a33eaedf9eae59191642f7a64e4.jpg)
使用不同的seaborn调色板
```python
>>> sns.set_color_codes("dark")
>>> _ = plt.plot([0, 1], color="g")
>>> _ = plt.plot([0, 2], color="m")
```
![http://seaborn.pydata.org/_images/seaborn-set_color_codes-2.png](img/35544ecf6de962c91ab860527035f39f.jpg)
# seaborn.reset_defaults
```py
seaborn.reset_defaults()
```
Restore all RC params to default settings.
\ No newline at end of file
# seaborn.reset_defaults
```python
seaborn.reset_defaults()
```
重置所有RC设置至默认设置。
\ No newline at end of file
# seaborn.reset_orig
```py
seaborn.reset_orig()
```
Restore all RC params to original settings (respects custom rc).
\ No newline at end of file
# seaborn.reset_orig
```python
seaborn.reset_orig()
```
将所有RC参数恢复为最初设置(相对于自定义rc而言)。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册