如何在matplotlib的散点图中设置点的边框颜色? [英] How to set the border color of the dots in matplotlib's scatterplots?

查看:138
本文介绍了如何在matplotlib的散点图中设置点的边框颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置通过 Axes.scatter 生成的点的边框颜色,还是始终为黑色?

Is it possible to set the color of the borders of the dots that are generated via the Axes.scatter or is it always black?

谢谢!

推荐答案

如果要使所有边缘都具有相同的颜色:

If you want to make all the edges the same color:

ax.scatter(...., edgecolor=EC)

其中 EC 是一种颜色.如果您想压迫边缘(看起来边缘颜色与面部颜色匹配),请使用

where EC is a color. If you want to surpress the edge (so it looks like the edge color matches the face color) use

ax.scatter(..., linewidths=0)

如果要使边缘的颜色与面部的颜色不同,并且每个标记都有其自己的颜色,则好像必须对自己进行映射:

If you want to have the edges be a different color than the face and each marker have it's own color it looks like you have to do the mapping your self:

my_cmap = cm.get_cmap('jet')
my_norm = matplotlib.colors.Normalize()
ec_data = rand(15)
my_normed_data = my_norm(ec_data)
ec_colors = my_cmap(my_normed_data) # a Nx4 array of rgba value
ax.scatter(rand(15), rand(15), s=500, c=rand(15), edgecolors=ec_colors, linewidth=3)

这篇关于如何在matplotlib的散点图中设置点的边框颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆