Let's say I have a list of color names (strings), like this:
samples = {{"blue, red, red"}, {"purple, blue, purple"}, {"blue, blue"}};
Then I can plot the frequency of the words (I remove spaces and split by commas in this case).
data = Flatten[
StringDelete[#, " "] & /@ (StringSplit[#, ","] & /@
Flatten[samples])];
chart = BarChart[Counts[data]/Length[data], ChartLabels -> Automatic,
Frame -> True]
How could I detect the 'categories' and make an appropiate color accordingly?
I look for something like ColorRules -> {"blue" -> Blue, "red" -> Red, "purple" -> Purple}
to make the color of each bar corresponding to the color category I'm showing here (I use strings representing colors as an example, in a general application, it can be anything, like {"birds"->Blue, "horses"->Red}
, etc)
Thanks!