我如何在Matplotlib中改变标记?

时间:2014-10-30 03:25:20

标签: python matplotlib

我尝试输入一个列表作为标记参数,但我一直收到一条错误,指出:

  

ValueError:无法识别的标记样式['','o','','','','',   'o','','','','','','','', 'o','','o','','','',   '','','','','','','o','',' ','o','','','o','',   '','','o','','','','o','','','','','','o','',   'o','','o','','','','','o','o','< / em>','o','','','',   'o','','','','','','','', '','','','','o','',   'o','o','o','','o','','','','',' ','','','','',   '','','','','o','','','', '','o','','','','',   '','','','o','','','','', '','','','','','',   '','','','','','o','','',' ','o','','','o','o',   'o','','o','o','o','','o','','',' ','o','','','',   'o','','o','','','','','','','','','o','o','',   '','','','','o','','','',' ','','','','','',   '','','o','','','','','', '','','','','','o',   '','','','','o','','','', '','','o','','','',   '','','','','','','','o', '','','','','','',   '','','','o','','','','o','','','','','','',   '','','*']

这是代码:

pure_accuracy_rate,report,y_pred,test_labels,test_data,neigh = nearest_neighbors(raw_data,nlabels)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')


plot_vars = ["SIO2","FEOT","MGO"]


x1,y1,z1 = [test_data[:,chemicals.index(x)] for x in plot_vars]
cmap = {1:"red",2:"green",3:"blue",4:"orange"}
hit_shapes = {True:"*",False:"o"}

hit_mat = [y_pred[i] == test_labels[i] for i in range(len(test_labels))]
hit_shapes_mat = [hit_shapes[i] for i in hit_mat]
rock_colors = [cmap[x] for x in test_labels]


ax.scatter(x1, y1, zs=z1, c=rock_colors, marker=hit_shapes_mat)

ax.set_xlabel(plot_vars[0])
ax.set_ylabel(plot_vars[1])
ax.set_zlabel(plot_vars[2])

有没有办法在matplotlib中提供标记列表?

1 个答案:

答案 0 :(得分:0)

显然,这是不可能的,您必须手动将数据集拆分为不同的标记组