• plt绘制 2维、3维散点图


    # 3维
    import
    numpy as np import matplotlib.pyplot as plt from sklearn.datasets.samples_generator import make_classification from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = Axes3D(fig) data,labels=make_classification(n_samples=1000,n_features=3,n_redundant=0,n_informative=2, random_state=1,n_clusters_per_class=2) unique_lables=set(labels) colors=plt.cm.Spectral(np.linspace(0,1,len(unique_lables))) for k,col in zip(unique_lables,colors): x_k=data[labels==k] ax.scatter3D(x_k[:,0],x_k[:,1],x_k[:, 2], c=col) # 开始绘制,x_k[:,0] 表示取第一维 plt.title('data by make_classification()') plt.show()
    # 2维
    
    
    import numpy as np
    import matplotlib.pyplot as plt
    from sklearn.datasets.samples_generator import make_classification
    data,labels=make_classification(n_samples=100,n_features=2,n_redundant=0,n_informative=2,
                                 random_state=5,n_clusters_per_class=2)
    unique_lables=set(labels)
    colors=plt.cm.Spectral(np.linspace(0,1,len(unique_lables)))
    for k,col in zip(unique_lables,colors):
        x_k=data[labels==k]
        plt.plot(x_k[:,0],x_k[:,1],'o',markerfacecolor=col,markeredgecolor="k",
        markersize=10)
    plt.title('data by make_classification()')
    plt.show()
  • 相关阅读:
    审 讯 技巧
    带参数的多线程的方式
    通达信日线 数据格式
    visual studio 2012 update3
    单实例运行tz
    维特比算法
    Kooboo CMS的安装步骤
    年龄
    富文本编辑器---非常实用的
    printf 打印 unit32_t
  • 原文地址:https://www.cnblogs.com/callyblog/p/10083885.html
Copyright © 2020-2023  润新知