python create adictionary randomly assigning clors to categorical vairables

Solutions on MaxInterview for python create adictionary randomly assigning clors to categorical vairables by the best coders in the world

showing results for - "python create adictionary randomly assigning clors to categorical vairables"
Juan
27 Jun 2016
1# Unique category labels: 'D', 'F', 'G', ...
2color_labels = df['color'].unique()
3
4# List of RGB triplets
5rgb_values = sns.color_palette("Set2", 8)
6
7# Map label to RGB
8color_map = dict(zip(color_labels, rgb_values))
9
10# Finally use the mapped values
11plt.scatter(df['carat'], df['price'], c=df['color'].map(color_map))
Eleonora
05 Apr 2016
1sns.palplot(sns.color_palette("Set2", 8))