Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an edge to scatter plot marker

I'm making a matplotlib plot in python. I have one marker that I am putting onto the plot using:

plt.scatter(x_position,y_position,c=z_position,cmap=cm.bwr,marker='x',s=500,linewidth=4)

As you can see, the color of the marker is a reflection of the z position.

My only problem is that sometimes the 'X' is not entirely distinct from the background (depending on the color of course), so I wanted to put a black outline around the 'X' marker.

I tried changing edgecolor, but this didn't seem to have an effect. I think this is because I have made the marker an 'X' and so there is no edge in the same way a regular circle scatter plot would have an edge?

like image 906
user1551817 Avatar asked Sep 13 '26 22:09

user1551817


1 Answers

You're using "x". That is an unfilled marker, like "+". If instead you use "X", it will be a filled marker, which can have a face- and an edgecolor.

plt.scatter([1,2,3], [1,2,3], c=[1,2,3], s=1000, marker="X", 
            linewidth=1, edgecolor='k')

plt.margins(1)
plt.show()

enter image description here

like image 116
ImportanceOfBeingErnest Avatar answered Sep 16 '26 12:09

ImportanceOfBeingErnest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!