plt.figure(facecolor = 'w')
    #面板分成3类
    cm_light = mpl.colors.ListedColormap(['#77E0A0', '#FF8080', '#A0A0FF'])
    #根据y的不同,填充颜色也不同
    plt.pcolormesh(x1, x2, y_hat, cmap=cm_light)

    plt.scatter(x[:, 0], x[:, 1], c='y')
    patchs = [mpatches.Patch(color='#77E0A0', label = 'Iris-setosa'),
              mpatches.Patch(color='#FF8080', label = 'Itis-versicolor'),
              mpatches.Patch(color = '#A0A0FF', label = 'Iris-virginica')]
    plt.legend(handles=patchs, fancybox = True, framealpha=0.8)
    plt.show()

 

相关文章:

  • 2021-05-27
  • 2021-10-27
  • 2022-02-04
  • 2021-10-16
  • 2021-07-11
  • 2021-12-16
  • 2021-08-16
  • 2022-12-23
猜你喜欢
  • 2021-08-29
  • 2021-09-25
  • 2022-12-23
  • 2021-05-09
  • 2021-11-17
  • 2021-09-30
相关资源
相似解决方案