Home > Net >  How to change individual markers when plotting with matplotlib
How to change individual markers when plotting with matplotlib

Time:10-03

I have the code below and am trying to figure out how to shape of markers in a matplotlib array. Specifically, the first marker point in the array should be a circle, and the second marker point in the array should be a square.

import matplotlib.pyplot as plt
import numpy as np

plt.title('Map')

plt.gca().invert_yaxis()

RedLineNames = np.array(["Tub Gallery","Maul Gallery","Rocket Gallery","ClasseArt Gallery ","Wiseworlds Gallery"])
RedLineCoords = np.array([[3950, 4250],[1350,450],[3550, 3200],[2500, 2500],[400, 2750]])

# Set marker points
plt.plot(RedLineCoords[:,0],RedLineCoords[:,1],marker='^',markersize=10,color='red')

# Draw connecting red line
plt.plot(RedLineCoords[:,0],RedLineCoords[:,1], 'r-')

# Add plot names
for i in range(len(RedLineCoords)):
    plt.text(RedLineCoords[i,0],RedLineCoords[i,1] 20,RedLineNames[i])
    
plt.show()

CodePudding user response:

  • Set the markers with a separate plot call
    • enter image description here

  • Related