close

How to customize marker colors and shapes in scatter plot?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to customize marker colors and shapes in scatter plot in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to customize marker colors and shapes in scatter plot?

  1. How to customize marker colors and shapes in scatter plot?

    Is this the type of thing you're after?
    from matplotlib import pyplot as plt #generate a list of markers and another of colors

  2. customize marker colors and shapes in scatter plot

    Is this the type of thing you're after?
    from matplotlib import pyplot as plt #generate a list of markers and another of colors

Method 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 in range(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

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read