sns color specific points

Solutions on MaxInterview for sns color specific points by the best coders in the world

showing results for - "sns color specific points"
Leah
05 Apr 2018
1import pandas as pd
2import numpy as np
3import matplotlib.pylab as plt
4import seaborn as sns
5 
6# Create data frame. The last column is the needed color
7df = pd.DataFrame(np.random.random((100,2)), columns=["x","y"])
8 
9# Add a column: the color depends of x and y values, but you can use whatever function.
10value=(df['x']>0.2) & (df['y']>0.4)
11df['color']= np.where( value==True , "#9b59b6", "#3498db")
12 
13# plot
14sns.regplot(data=df, x="x", y="y", fit_reg=False, scatter_kws={'facecolors':df['color']})
15#sns.plt.show()