Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python create adictionary randomly assigning clors to categorical vairables

# Unique category labels: 'D', 'F', 'G', ...
color_labels = df['color'].unique()

# List of RGB triplets
rgb_values = sns.color_palette("Set2", 8)

# Map label to RGB
color_map = dict(zip(color_labels, rgb_values))

# Finally use the mapped values
plt.scatter(df['carat'], df['price'], c=df['color'].map(color_map))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #create #adictionary #randomly #assigning #clors #categorical #vairables
ADD COMMENT
Topic
Name
1+8 =