<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # seaborn.boxplot > 譯者:[FindNorthStar](https://github.com/FindNorthStar) ```py seaborn.boxplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, width=0.8, dodge=True, fliersize=5, linewidth=None, whis=1.5, notch=False, ax=None, **kwargs) ``` seaborn.boxplot 接口的作用是繪制箱形圖以展現與類別相關的數據分布狀況。 箱形圖(或盒須圖)以一種利于變量之間比較或不同分類變量層次之間比較的方式來展示定量數據的分布。圖中矩形框顯示數據集的上下四分位數,而矩形框中延伸出的線段(觸須)則用于顯示其余數據的分布位置,剩下超過上下四分位間距的數據點則被視為“異常值”。 輸入數據可以通過多種格式傳入,包括: * 格式為列表,numpy 數組或 pandas Series 對象的數據向量可以直接傳遞給`x`,`y`和`hue`參數。 * 對于長格式的 DataFrame,`x`,`y`,和`hue`參數會決定如何繪制數據。 * 對于寬格式的 DataFrame,每一列數值列都會被繪制。 * 一個數組或向量的列表。 在大多數情況下,可以使用 numpy 或 Python 對象,但更推薦使用 pandas 對象,因為與數據關聯的列名/行名可以用于標注橫軸/縱軸的名稱。此外,您可以使用分類類型對變量進行分組以控制繪圖元素的順序。 此函數始終將其中一個變量視為分類,并在相關軸上的序數位置(0,1,... n)處繪制數據,即使數據屬于數值類型或日期類型也是如此。 更多信息請參閱 [教程](http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial)。 參數:`x, y, hue`:`數據`或向量數據中的變量名稱,可選 > 用于繪制長格式數據的輸入。查看樣例以進一步理解。 `data`:DataFrame,數組,數組列表,可選 > 用于繪圖的數據集。如果`x`和`y`都缺失,那么數據將被視為寬格式。否則數據被視為長格式。 `order, hue_order`:字符串列表,可選 > 控制分類變量(對應的條形圖)的繪制順序,若缺失則從數據中推斷分類變量的順序。 `orient`:“v” &#124; “h”,可選 > 控制繪圖的方向(垂直或水平)。這通常是從輸入變量的 dtype 推斷出來的,但是當“分類”變量為數值型或繪制寬格式數據時可用于指定繪圖的方向。 `color`:matplotlib 顏色,可選 > 所有元素的顏色,或漸變調色板的種子顏色。 `palette`:調色板名稱,列表或字典,可選 > 用于`hue`變量的不同級別的顏色。可以從 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解釋,或者將色調級別映射到 matplotlib 顏色的字典。 `saturation`:float,可選 > 控制用于繪制顏色的原始飽和度的比例。通常大幅填充在輕微不飽和的顏色下看起來更好,如果您希望繪圖顏色與輸入顏色規格完美匹配可將其設置為`1`。 `width`:float,可選 > 不使用色調嵌套時完整元素的寬度,或主要分組變量一個級別的所有元素的寬度。 `dodge`:bool,可選 > 使用色調嵌套時,元素是否應沿分類軸移動。 `fliersize`:float,可選 > 用于表示異常值觀察的標記的大小。 `linewidth`:float,可選 > 構圖元素的灰線寬度。 `whis`:float,可選 > 控制在超過高低四分位數時 IQR 的比例,因此需要延長繪制的觸須線段。超出此范圍的點將被識別為異常值。 `notch`:boolean,可選 > 是否使矩形框“凹陷”以指示中位數的置信區間。還有其他幾個參數可以控制凹槽的繪制方式;參見 `plt.boxplot` 以查看關于此問題的更多幫助信息。 `ax`:matplotlib 軸,可選 > 繪圖時使用的 Axes 軸對象,否則使用當前 Axes 軸對象。 `kwargs`:鍵,值映射 > 其他在繪圖時傳給 `plt.boxplot` 的參數。 返回值:`ax`:matplotlib 軸 > 返回 Axes 對軸象,并在其上繪制繪圖。 亦可參見 boxplot 和核密度估計的結合。當一個變量是分類變量的散點圖。可以與其他圖表結合使用以展示各自的觀測結果。分類散點圖的特點是其中數據點互不重疊。可以與其他圖表結合使用以展示各自的觀測結果。 示例 繪制一個單獨的橫向箱型圖: ```py >>> import seaborn as sns >>> sns.set(style="whitegrid") >>> tips = sns.load_dataset("tips") >>> ax = sns.boxplot(x=tips["total_bill"]) ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-1.png](https://img.kancloud.cn/e7/61/e76197f5ae734dbacd871615afd47ad0_576x432.jpg) 根據分類變量分組繪制一個縱向的箱型圖: ```py >>> ax = sns.boxplot(x="day", y="total_bill", data=tips) ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-2.png](https://img.kancloud.cn/6c/3b/6c3bbaf62f07d3b07859a4f2ea424f45_576x432.jpg) 根據 2 個分類變量嵌套分組繪制一個箱型圖: ```py >>> ax = sns.boxplot(x="day", y="total_bill", hue="smoker", ... data=tips, palette="Set3") ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-3.png](https://img.kancloud.cn/8e/28/8e2874781f0c709d6c8ab28061513f8b_576x432.jpg) 當一些數據為空時根據嵌套分組繪制一個箱型圖: ```py >>> ax = sns.boxplot(x="day", y="total_bill", hue="time", ... data=tips, linewidth=2.5) ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-4.png](https://img.kancloud.cn/69/fc/69fcd9d5024c31c516a8fe0a0d31a139_576x432.jpg) 通過顯式傳入參數指定順序控制箱型圖的顯示順序: ```py >>> ax = sns.boxplot(x="time", y="tip", data=tips, ... order=["Dinner", "Lunch"]) ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-5.png](https://img.kancloud.cn/6c/8d/6c8de8b65d648ec11a8f82ba314738d4_576x432.jpg) 針對 DataFrame 里每一個數值型變量繪制箱型圖: ```py >>> iris = sns.load_dataset("iris") >>> ax = sns.boxplot(data=iris, orient="h", palette="Set2") ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-6.png](https://img.kancloud.cn/28/4f/284f314cca118f42ae34e7eee44eea06_576x432.jpg) 使用 `hue` 參數無需改變箱型圖的位置或寬度: ```py >>> tips["weekend"] = tips["day"].isin(["Sat", "Sun"]) >>> ax = sns.boxplot(x="day", y="total_bill", hue="weekend", ... data=tips, dodge=False) ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-7.png](https://img.kancloud.cn/93/35/93350e99c6ea8f3b5800bb40d13e7c62_576x432.jpg) 使用 [`swarmplot()`](seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot") 展示箱型圖頂部的數據點: ```py >>> ax = sns.boxplot(x="day", y="total_bill", data=tips) >>> ax = sns.swarmplot(x="day", y="total_bill", data=tips, color=".25") ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-8.png](https://img.kancloud.cn/24/36/2436998a15a98c12059671ca8d41e1e2_576x432.jpg) 把 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 與 [`pointplot()`](seaborn.pointplot.html#seaborn.pointplot "seaborn.pointplot") 以及 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 結合起來使用。這允許您通過額外的分類變量進行分組。使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更為安全,因為它保證了不同切面上變量同步的順序: ```py >>> g = sns.catplot(x="sex", y="total_bill", ... hue="smoker", col="time", ... data=tips, kind="box", ... height=4, aspect=.7); ``` ![http://seaborn.pydata.org/_images/seaborn-boxplot-9.png](https://img.kancloud.cn/f1/c2/f1c2990b44b3f11289444d58faa38405_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>

                              哎呀哎呀视频在线观看