代码之家  ›  专栏  ›  技术社区  ›  mahmood

箱线图不显示这些图

  •  0
  • mahmood  · 技术社区  · 4 年前

    接下来 tutorial ,我使用前几条语句来显示iris数据的分布,如下所示

    from sklearn.datasets import load_iris
    from pandas import DataFrame
    import numpy as np
    iris = load_iris()
    colors = ["blue", "red", "green"]
    df = DataFrame(
        data=np.c_[iris["data"], iris["target"]], columns=iris["feature_names"] + ["target"]
    )
    print (df)
    df.boxplot(by="target", layout=(2, 2), figsize=(10, 10))
    

    问题是,虽然 df 不是空的。

    $ python3 pca_iris.py
         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
    ..                 ...               ...                ...               ...     ...
    145                6.7               3.0                5.2               2.3     2.0
    146                6.3               2.5                5.0               1.9     2.0
    147                6.5               3.0                5.2               2.0     2.0
    148                6.2               3.4                5.4               2.3     2.0
    149                5.9               3.0                5.1               1.8     2.0
    
    [150 rows x 5 columns]
    $
    

    如何进行更多调试以了解boxplot的问题所在?

    0 回复  |  直到 4 年前
        1
  •  1
  •   Mehdi Golzadeh    4 年前

    我用的是jupyter笔记本,同样的代码显示了情节。如果你使用python代码,我想你必须使用

    matplotlib.pyplot.show()
    

    看看情节