user1551817
user1551817

Reputation: 7451

Change the marker thickness in matplotlib scatter plot

I have the following marker in my python matplotlib scatter plot:

enter image description here

made by the code:

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

I want the X to be the same size, but I want the red part to be 'thinner'. More like a real 'X' I guess.

Is this possible?

Thank you.

Upvotes: 5

Views: 6628

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339170

The thicker the edge, the thinner the face. Alternatively a marker "x" can be used

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

Upvotes: 11

Related Questions