• <legend id='zlZfW'><style id='zlZfW'><dir id='zlZfW'><q id='zlZfW'></q></dir></style></legend>
  • <tfoot id='zlZfW'></tfoot>

        <small id='zlZfW'></small><noframes id='zlZfW'>

        <i id='zlZfW'><tr id='zlZfW'><dt id='zlZfW'><q id='zlZfW'><span id='zlZfW'><b id='zlZfW'><form id='zlZfW'><ins id='zlZfW'></ins><ul id='zlZfW'></ul><sub id='zlZfW'></sub></form><legend id='zlZfW'></legend><bdo id='zlZfW'><pre id='zlZfW'><center id='zlZfW'></center></pre></bdo></b><th id='zlZfW'></th></span></q></dt></tr></i><div id='zlZfW'><tfoot id='zlZfW'></tfoot><dl id='zlZfW'><fieldset id='zlZfW'></fieldset></dl></div>
        • <bdo id='zlZfW'></bdo><ul id='zlZfW'></ul>

        具有多个分布的海运距离图/离散图

        seaborn distplot / displot with multiple distributions(具有多个分布的海运距离图/离散图)

          <legend id='ZhoBW'><style id='ZhoBW'><dir id='ZhoBW'><q id='ZhoBW'></q></dir></style></legend>
            1. <tfoot id='ZhoBW'></tfoot>

                <small id='ZhoBW'></small><noframes id='ZhoBW'>

                  <tbody id='ZhoBW'></tbody>
                • <bdo id='ZhoBW'></bdo><ul id='ZhoBW'></ul>
                  <i id='ZhoBW'><tr id='ZhoBW'><dt id='ZhoBW'><q id='ZhoBW'><span id='ZhoBW'><b id='ZhoBW'><form id='ZhoBW'><ins id='ZhoBW'></ins><ul id='ZhoBW'></ul><sub id='ZhoBW'></sub></form><legend id='ZhoBW'></legend><bdo id='ZhoBW'><pre id='ZhoBW'><center id='ZhoBW'></center></pre></bdo></b><th id='ZhoBW'></th></span></q></dt></tr></i><div id='ZhoBW'><tfoot id='ZhoBW'></tfoot><dl id='ZhoBW'><fieldset id='ZhoBW'></fieldset></dl></div>
                  本文介绍了具有多个分布的海运距离图/离散图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用海运绘制分布图。我想在同一张图上用不同的颜色绘制多个分布:

                  下面是我开始绘制分布图的方式:

                  import numpy as np
                  import pandas as pd
                  from sklearn.datasets import load_iris
                  iris = load_iris()
                  iris = pd.DataFrame(data= np.c_[iris['data'], iris['target']],columns= iris['feature_names'] + ['target'])
                  
                     sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)  target
                  0                5.1               3.5                1.4               0.2     0.0
                  1                4.9               3.0                1.4               0.2     0.0
                  2                4.7               3.2                1.3               0.2     0.0
                  3                4.6               3.1                1.5               0.2     0.0
                  4                5.0               3.6                1.4               0.2     0.0
                  
                  sns.distplot(iris[['sepal length (cm)']], hist=False, rug=True);
                  

                  'target'列包含3个值:0、1、2。

                  我希望看到一个萼片长度分布图,其中target ==0target ==1target ==2共有3个分布图。

                  推荐答案

                  重要的是按target012的值对数据帧进行排序。

                  import numpy as np
                  import pandas as pd
                  from sklearn.datasets import load_iris
                  import seaborn as sns
                  
                  iris = load_iris()
                  iris = pd.DataFrame(data=np.c_[iris['data'], iris['target']],
                                      columns=iris['feature_names'] + ['target'])
                  
                  # Sort the dataframe by target
                  target_0 = iris.loc[iris['target'] == 0]
                  target_1 = iris.loc[iris['target'] == 1]
                  target_2 = iris.loc[iris['target'] == 2]
                  
                  sns.distplot(target_0[['sepal length (cm)']], hist=False, rug=True)
                  sns.distplot(target_1[['sepal length (cm)']], hist=False, rug=True)
                  sns.distplot(target_2[['sepal length (cm)']], hist=False, rug=True)
                  
                  plt.show()
                  

                  输出如下:

                  如果您不知道target可能有多少值,请在target列中找到唯一的值,然后对数据帧进行切片并相应地添加到绘图中。

                  import numpy as np
                  import pandas as pd
                  from sklearn.datasets import load_iris
                  import seaborn as sns
                  
                  iris = load_iris()
                  iris = pd.DataFrame(data=np.c_[iris['data'], iris['target']],
                                      columns=iris['feature_names'] + ['target'])
                  
                  unique_vals = iris['target'].unique()  # [0, 1, 2]
                  
                  # Sort the dataframe by target
                  # Use a list comprehension to create list of sliced dataframes
                  targets = [iris.loc[iris['target'] == val] for val in unique_vals]
                  
                  # Iterate through list and plot the sliced dataframe
                  for target in targets:
                      sns.distplot(target[['sepal length (cm)']], hist=False, rug=True)
                  

                  这篇关于具有多个分布的海运距离图/离散图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                    <bdo id='LWMPb'></bdo><ul id='LWMPb'></ul>

                    <tfoot id='LWMPb'></tfoot>
                          <tbody id='LWMPb'></tbody>
                      1. <i id='LWMPb'><tr id='LWMPb'><dt id='LWMPb'><q id='LWMPb'><span id='LWMPb'><b id='LWMPb'><form id='LWMPb'><ins id='LWMPb'></ins><ul id='LWMPb'></ul><sub id='LWMPb'></sub></form><legend id='LWMPb'></legend><bdo id='LWMPb'><pre id='LWMPb'><center id='LWMPb'></center></pre></bdo></b><th id='LWMPb'></th></span></q></dt></tr></i><div id='LWMPb'><tfoot id='LWMPb'></tfoot><dl id='LWMPb'><fieldset id='LWMPb'></fieldset></dl></div>
                        1. <legend id='LWMPb'><style id='LWMPb'><dir id='LWMPb'><q id='LWMPb'></q></dir></style></legend>
                        2. <small id='LWMPb'></small><noframes id='LWMPb'>