Skip to content Skip to sidebar Skip to footer

How To Customize Marker Colors And Shapes In Scatter Plot?

I have a data set with 9 columns. 7 features are used for feature selection and one of them for the classification. I used tsne library for feature selection in order to see how m

Solution 1:

Is this the type of thing you're after?

from matplotlib import pyplot as plt 

#generate a list of markers and another of colors 
markers = ["." , "," , "o" , "v" , "^" , "<", ">"]
colors = ['r','g','b','c','m', 'y', 'k']

#make a sample dataset
x = np.arange(0,10)  #test x values.. every feature gets the same x values but you can generalize this
y = [s*x for s in np.arange(7)] #generate 7 arrays of y values for i inrange(7): #for each of the 7 features 
    mi = markers[i] #marker for ith feature 
    xi = x #x array for ith feature .. here is where you would generalize      different x for every feature
    yi = y[i] #y array for ith feature 
    ci = colors[i] #color for ith feature 
    plt.scatter(xi,yi,marker=mi, color=ci) 
plt.show() 

enter image description here

Post a Comment for "How To Customize Marker Colors And Shapes In Scatter Plot?"