3、barplot函數:條形圖可視化
seaborn.barplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean at 0x7fecadf1cee0>, ci=95, n_boot=1000, units=None, seed=None, orient=None, color=None, palette=None, saturation=0.75, errcolor='.26', errwidth=None, capsize=None, dodge=True, ax=None, **kwargs)
僅第2變量必須為數值型
條形圖表示數值變量與每個矩形高度的中心趨勢的估計值(預設平均值),并使用誤差條提供關于該估計值附近的不确定性的一些訓示。誤差條越長,資料離散程度越大,資料越不穩定。
官方文檔解釋:
http://seaborn.pydata.org/generated/seaborn.barplot.html?highlight=barplot#seaborn.barplotShow 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.
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.
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.
用矩形條顯示點估計和置信區間。
條形圖表示對每個矩形高度的數值變量的集中趨勢的估計,并使用誤差條提供了一些關于估計的不确定性的訓示。條形圖在數量軸範圍中包括0,當0是數量變量的一個有意義的值,并希望與之進行比較時,條形圖是一個很好的選擇。
對于0不是一個有意義的值的資料集,點圖将允許你關注一個或多個分類變量的不同級别。
同樣重要的是要記住,條形圖隻顯示平均值(或其他估計值),但在許多情況下,顯示分類變量每一級的值分布可能會提供更多資訊。在這種情況下,其他方法,如盒子或小提琴情節可能更合适。
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.
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
輸入資料可以以多種格式傳遞,包括:
表示為清單、numpy數組或pandas系列對象的資料向量,直接傳遞給x、y和/或hue參數。
一個“長格式”資料幀,在這種情況下,x, y和hue變量将決定資料如何繪制。
一種“寬格式”資料幀,這樣每個數字列都将被繪制出來。
向量的數組或清單。
在大多數情況下,可以使用numpy或Python對象,但pandas對象更合适,因為關聯的名稱将用于注釋坐标軸。此外,您可以為分組變量使用類别類型來控制繪圖元素的順序。
該函數總是将其中一個變量視為類别變量,并在相關軸上的順序位置(0,1,…n)繪制資料,即使資料具有numeric 或date 類型。
(1)、BarPlot

(2)、BarPlotByV
(3)、BarPlotBy2V
4、pointplot函數:點估計和置信區間可視化(誤差條)
seaborn.pointplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean at 0x7fecadf1cee0>, ci=95, n_boot=1000, units=None, seed=None, markers='o', linestyles='-', dodge=False, join=True, scale=1, orient=None, color=None, palette=None, errwidth=None, capsize=None, ax=None, **kwargs)
置信區間估計:圖中的點為該組資料的平均值點,豎線則為誤差條,預設兩個均值點會相連接配接
http://seaborn.pydata.org/generated/seaborn.pointplot.html?highlight=pointplot#seaborn.pointplotShow point estimates and confidence intervals using scatter plot glyphs.
A point plot represents an estimate of central tendency for a numeric variable by the position of scatter plot points and provides some indication of the uncertainty around that estimate using error bars.
Point plots can be more useful than bar plots for focusing comparisons between different levels of one or more categorical variables. They are particularly adept at showing interactions: how the relationship between levels of one categorical variable changes across levels of a second categorical variable. The lines that join each point from the same hue level allow interactions to be judged by differences in slope, which is easier for the eyes than comparing the heights of several groups of points or bars.
It is important to keep in mind that a point 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.
使用散點圖符号顯示點估計和置信區間。
點圖通過散點的位置表示對數值變量的集中趨勢的估計,并使用誤差條提供一些關于估計的不确定性的訓示。
點圖比條形圖更有助于集中比較一個或多個分類變量的不同層次。他們特别擅長展示互動作用:一個分類變量的各個層次之間的關系如何在另一個分類變量的各個層次之間發生變化。連接配接來自同一色調等級的每個點的線條允許通過斜率的差異來判斷互動作用,這比比較幾組點或條的高度更容易。
重要的是要記住點圖隻顯示平均值(或其他估計值),但在許多情況下,顯示分類變量的每一級值的分布可能會提供更多的資訊。在這種情況下,其他方法,如盒子或小提琴情節可能更合适。
該函數總是将其中一個變量視為類别變量,并在相關軸上的順序位置(0,1,…n)繪制資料,即使資料具有數字或日期類型。
5、stripplot函數:散點圖可視化
seaborn.stripplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, jitter=True, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)
http://seaborn.pydata.org/generated/seaborn.stripplot.html?highlight=stripplot#seaborn.stripplotDraw a scatterplot where one variable is categorical.
A strip plot can be drawn on its own, but it is also a good complement to a box or violin plot in cases where you want to show all observations along with some representation of the underlying distribution.
繪制一個散點圖,其中一個變量是類别變量。
條形圖可以自己繪制,但在您想要顯示所有觀察結果以及一些潛在分布的表示的情況下,它也是盒形圖或小提琴形圖的一個很好的補充。
在大多數情況下,可以使用numpy或Python對象,但pandas對象更合适,因為關聯的名稱将用于注釋坐标軸。此外,您可以為分組變量使用類别類型來控制情節元素的順序。
6、relplot函數:散點圖/折線圖可視化
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='auto', kind='scatter', height=5, aspect=1, facet_kws=None, units=None, **kwargs)
http://seaborn.pydata.org/generated/seaborn.relplot.html?highlight=relplot#seaborn.relplotFigure-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:
scatterplot() (with kind="scatter"; the default)
lineplot() (with 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.
See the tutorial for more information.
用于在FacetGrid上繪制關系圖的圖形級接口。
這個函數提供了對幾個不同的軸級函數的通路,這些函數顯示了兩個具有子集語義映射的變量之間的關系。kind參數選擇要使用的axis級函數:
額外的關鍵字參數被傳遞給底層函數,是以您應該參考每個函數的文檔來檢視特定種類的選項。
x和y之間的關系可以通過使用hue、size和style參數來顯示資料的不同子集。這些參數控制使用什麼視覺語義來辨別不同的子集。通過使用這三種語義類型,我們可以獨立呈現出三個次元,但這種繪圖風格很難解釋,而且通常是無效的。使用備援的語義(例如,相同變量的色調和樣式)有助于讓圖形更容易通路。
有關更多資訊,請參閱本教程。
The default treatment of the hue (and to a lesser extent, size) semantic, if present, depends on whether the variable is inferred to represent “numeric” or “categorical” data. In particular, numeric variables are represented with a sequential colormap by default, and the legend entries show regular “ticks” with values that may or may not exist in the data. This behavior can be controlled through various parameters, as described and illustrated below.
After plotting, the FacetGrid with the plot is returned and can be used directly to tweak supporting plot details or add other layers.
如果存在色相(以及較小程度上的大小)語義的預設處理,則取決于該變量是被推斷為表示“numeric”還是“categorical”資料。具體來說,預設情況下,數值變量用順序的colormap表示,并且圖例條目顯示有規律的“刻度”,刻度的值可能存在于資料中,也可能不存在。這種行為可以通過各種參數來控制,如下面的描述和說明所示。
繪制後,傳回帶有plot的FacetGrid,可以直接用于調整支援的plot細節或添加其他層。