python plt颜色标签

python plt颜色标签,python,scatter-plot,graph-coloring,Python,Scatter Plot,Graph Coloring,这是一个值得怀疑的问题 # x,y,size 데이터 셋팅 x = target_data.accuracy y = target_data.f1_score s = target_data.recall # 라벨셋팅(순서유의) users =['dnn', 'random forest', 'extra trees', 'ensemble'] 我确定设置了颜色数组并匹配了图形 生成的图像具有图形和标签,但颜色表示为黑白图像。 有什么问题吗?没有问题,但是您的(颜色贴图)默认为颜色贴图,

这是一个值得怀疑的问题

# x,y,size 데이터 셋팅
x = target_data.accuracy
y =  target_data.f1_score
s = target_data.recall

# 라벨셋팅(순서유의)
users =['dnn', 'random forest', 'extra trees', 'ensemble']
我确定设置了颜色数组并匹配了图形

生成的图像具有图形和标签,但颜色表示为黑白图像。
有什么问题吗?

没有问题,但是您的(颜色贴图)默认为颜色贴图,其中数字映射为不透明度。你可以从这个长长的列表中选择任何你喜欢的内容:并得到一个非常丰富多彩的情节

# 컬러셋팅
colors =  list(np.array([0.81520346,0.28735556, 0.6542928, 0.3542928]))
df = pd.DataFrame(dict(accuracy=x, f1_score=y, users=users, s=s, c=colors ))

# 그래프 그리기
ax = df.plot.scatter(x='accuracy', y='f1_score', s=df.s*10,c= df.c,  alpha=0.5)
for i, txt in enumerate(users):
    ax.annotate(txt, (df.accuracy.iat[i],df.f1_score.iat[i]))
plt.show()

如果您仅使用标量数字进行颜色设置,它将映射到一个colormap,默认情况下,它是rc image.cmap——默认情况下为灰度。因此,您可以另外设置另一个颜色映射(如
cmap='viridis'
或其他任何内容),或者将颜色定义为颜色名称、rgb(a)元组或rgb十六进制值:

示例:

ax = df.plot.scatter(x='accuracy', y='f1_score', s=df.s*10,c= df.c, 
                 alpha=0.5, cmap='PuOr') # added cmap
colors = ['r', 'g', 'b', 'm']
colors = [[.2, .3, .4], [.7, .3, .4], [.2, .9, .4], [.2, .3, .0]]
colors = ['#a0ff45', '#123456', '#fedcba', '#00ff77']