在matplotlib散点图中更改标记厚度

问题描述 投票:0回答:1

我的python matplotlib散点图中有以下标记:

enter image description here

由代码制作:

plt.scatter(x,y,c=z,cmap=cm.bwr,marker='X',s=800,linewidth=1,edgecolor='k')

我希望X的尺寸相同,但我希望红色部分“更薄”。更像是一个真正的'X'我猜。

这可能吗?

谢谢。

python matplotlib marker
1个回答
1
投票

边缘越厚,脸部越薄。或者,可以使用标记"x"

import matplotlib.pyplot as plt


for lw in [1,3,5,7]:
    plt.scatter([lw], [1], c="gold", s=1000, marker="X", 
                linewidth=lw, edgecolor='k')
    plt.scatter([lw], [0], c="gold", s=lw*300, marker="x")

plt.margins(.2)
plt.show()

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.