python - Different color for each set in scatter plot on matplotlib -


i have 2 samples sets multivariate normal distribution: ¿how set different color each set in scatter plot on matplotlib? eg. printing values a1 in blue , values a2 in red.

n= 4 a1 = np.random.multivariate_normal(mean=[1,-4], cov=[[2,-1],[-1,2]],size = n) a2 = np.random.multivariate_normal(mean=[1,-3], cov=[[1,1.5],[1.5,3]],size= n)   >>>print a1 [[ 0.16820131 -2.14909926]  [ 0.57792273 -2.43727122]  [-0.06946973 -3.72143292]  [ 2.59454949 -5.34776438]]  >>>print a2 [[ 0.98396671 -1.68934158] [-0.33756576 -3.28187214] [ 1.49767632 -3.46575623] [ 1.47036718 -1.58453858]] 

could me? in advance.

this should work you.

import numpy np import matplotlib.pyplot plt  np.random.seed(42) n = 1000 a1 = np.random.multivariate_normal(mean=[1,-4], cov=[[2,-1],[-1,2]],size = n) a2 = np.random.multivariate_normal(mean=[1,-3], cov=[[1,1.5],[1.5,3]],size= n)   fig, ax = plt.subplots() ax.scatter(a1[:,0], a1[:,1], color="blue", alpha=0.2) ax.scatter(a2[:,0], a2[:,1], color="red", alpha=0.2) 

enter image description here


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -