<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 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 值沒有實際意義的情況,散點圖可以讓您專注于一個或多個分類變量之間的差異。 要注意的是,條形圖只顯示平均值(或者其他的估計值),但是在大部分情況下,展示數值在不同分類變量上的分布會更有用。如果要表示出數據的分布,用箱型圖或者小提琴圖會更恰當。 輸入數據的格式可以不同,包括: * 以列表,numpy array 或者 pandas 中的 Series object 表示的向量。這些向量可以直接傳入 `x`, `y`, 以及 `hue` 參數。 * 長表, x 值,y 值和色相變量決定了數據是如何繪制的。 * 寬表,每個列的數值都會被繪制出來. * 數組或者列表的向量。 大多數情況下,您可以使用 numpy 的對象或者 python 的對象,但是用 pandas 對象更好,因為相關的列名會被標注在圖標上。 另外,為了控制繪圖元素 您也可以可以用分類類型來組合不同的變量。 這個函數始終把一個變量當做分類變量,即使這個數據是數值類型或者日期類型,并且按照序數順序繪制在相關的軸上。 詳情請看[教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)。 參數:`x, y, hue`:`data` 中的變量名詞或者向量, optional > 用于繪制 long-form 數據的變量名稱. `data`:DataFrame, 數組, 數組列表, optional > 用于繪圖的數據集。如果數據集有 x 和 y,數據集會被認為是 long-form,否則會被認為是 wide-form。 `order, hue_order`:字符串列表, optional > 繪制類別變量的順序,如果沒有,則從數據對象中推斷繪圖順序。 `estimator`:映射向量 -&gt; 標量, optional > 統計函數用于估計每個分類紙條中的值。. `ci`:float or “sd” or None, optional > 估計值周圍的置信區間大小。如果輸入的是 “sd”(標準差),會跳過 bootstrapping 的過程,只繪制數據的標準差。 如果輸入是的是`None`, 不會執行 botstrapping,而且錯誤條也不會繪制。 `n_boot`:int, optional > 計算置信區間需要的 Boostrap 迭代次數。 `units`:name of variable in `data` or vector data, optional > 采樣單元的標識符,用于執行多級 bootstrap 并解釋重復測量設計。 `orient`:“v” &#124; “h”, optional > 繪圖的方向(垂直或水平)。這通常是從輸入變量的數據類型推斷出來的,但是可以用來指定“分類”變量是數字還是寬格式數據。 `color`:matplotlib color, optional > 作用于所有元素的顏色,或者漸變色的種子。 `palette`:palette name, list, or dict, optional > 不同級別的 `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. `errcolor`:matplotlib color > 表示置信區間的線的顏色。 `errwidth`:float, optional > 誤差條的線的厚度。 `capsize`:float, optional > 誤差條端部的寬度。 **dodge** : 布爾型, optional > When hue nesting is used, whether elements should be shifted along the categorical axis. `ax`:matplotlib Axes, optional > 指定一個 Axes 用于繪圖,如果不指定,則使用當前的 Axes。 `kwargs`:key, value mappings > 其他的關鍵詞參數在繪圖時通過 `plt.bar` 傳入。 返回值:`ax`:matplotlib Axes > 返回有圖表繪制的 Axes 對象。 See also 顯示每個分類 bin 中的觀察計數。使用散點圖圖示符顯示點估計和置信區間。將分類圖與類相結合:<cite>FacetGrid</cite>. Examples 繪制一組按類別變量分組的垂直條形圖: ```py >>> import seaborn as sns >>> sns.set(style="whitegrid") >>> tips = sns.load_dataset("tips") >>> ax = sns.barplot(x="day", y="total_bill", data=tips) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-1.png](https://img.kancloud.cn/9c/3a/9c3a8021d993ae3d2b55cfd9f898ca60_576x432.jpg) 繪制一組由兩個變量嵌套分組的垂直條形圖: ```py >>> ax = sns.barplot(x="day", y="total_bill", hue="sex", data=tips) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-2.png](https://img.kancloud.cn/10/37/10375cca6f343434ebea407db3a466c7_576x432.jpg) 繪制一組水平條形圖: ```py >>> ax = sns.barplot(x="tip", y="day", data=tips) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-3.png](https://img.kancloud.cn/2b/61/2b619c1991180c08ea868f40486452a5_576x432.jpg) 通過傳入一個顯式的順序來控制條柱的順序: ```py >>> ax = sns.barplot(x="time", y="tip", data=tips, ... order=["Dinner", "Lunch"]) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-4.png](https://img.kancloud.cn/10/ae/10aed048df152a299ab3d6acfb89342a_576x432.jpg) 用中值來評估數據的集中趨勢: ```py >>> from numpy import median >>> ax = sns.barplot(x="day", y="tip", data=tips, estimator=median) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-5.png](https://img.kancloud.cn/78/c3/78c3b31d3a6ced1419e43f14de5bc682_576x432.jpg) 用誤差條顯示平均值的標準誤差: ```py >>> ax = sns.barplot(x="day", y="tip", data=tips, ci=68) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-6.png](https://img.kancloud.cn/c9/78/c97879bdb982626e9d7728981cc4d394_576x432.jpg) 展示數據的標準差: ```py >>> ax = sns.barplot(x="day", y="tip", data=tips, ci="sd") ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-7.png](https://img.kancloud.cn/27/b4/27b47fdd3d30162f09925d304cf8cd01_576x432.jpg) 給誤差條增加“端點”: ```py >>> ax = sns.barplot(x="day", y="tip", data=tips, capsize=.2) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-8.png](https://img.kancloud.cn/13/d7/13d78f70b72a84d56b30a5f256098fa2_576x432.jpg) 使用一個不同的調色盤來繪制圖案: ```py >>> ax = sns.barplot("size", y="total_bill", data=tips, ... palette="Blues_d") ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-9.png](https://img.kancloud.cn/55/0b/550be1199085a55e3649187c2aa7239b_576x432.jpg) 在不改變條柱的位置或者寬度的前提下,使用 `hue` : ```py >>> tips["weekend"] = tips["day"].isin(["Sat", "Sun"]) >>> ax = sns.barplot(x="day", y="total_bill", hue="weekend", ... data=tips, dodge=False) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-10.png](https://img.kancloud.cn/49/ca/49ca637f1c5d36ad3b52e954c74c3fd8_576x432.jpg) 用同一種顏色繪制所有條柱: ```py >>> ax = sns.barplot("size", y="total_bill", data=tips, ... color="salmon", saturation=.5) ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-11.png](https://img.kancloud.cn/51/ee/51ee73fc4ec8a78face9c94156c3d043_576x432.jpg) 用 `plt.bar` 關鍵字參數進一步改變圖表的樣式: ```py >>> ax = sns.barplot("day", "total_bill", data=tips, ... linewidth=2.5, facecolor=(1, 1, 1, 0), ... errcolor=".2", edgecolor=".2") ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-12.png](https://img.kancloud.cn/bc/71/bc71adf299694ffc3e247a7156d2e1a8_576x432.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 之間保持同步: ```py >>> g = sns.catplot(x="sex", y="total_bill", ... hue="smoker", col="time", ... data=tips, kind="bar", ... height=4, aspect=.7); ``` ![http://seaborn.pydata.org/_images/seaborn-barplot-13.png](https://img.kancloud.cn/b0/25/b025097a19f24846d62d631b42aa3907_577x360.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看