MATLAB Answers

Grouped Bar Plot coloring - specific colors for specific indexes in a particular group

1 view (last 30 days)
Kyle Stanhouse
Kyle Stanhouse on 5 Dec 2013
I am trying to get a grouped bar plot with different colors for specific indexes within a group (not setting the colors for each whole group!). That is, for group 1 (of 3 groups for each index or x value ), I need some of them to be one color and others to be a different color. I've searched the question and answers on the board and I've seen 'looped' solutions for non-grouped bar plots but I can't figure out how to access the handle of a particular index of a group and manually set it's color.
My bar plot looks something like this: bar([x_idxs],[[y_vals group 1] [y_vals group 2] [y_vals group 3]]);
I've figured out how to change the color of any one of the groups to be what i want using 'set' and 'get' (and cdata or through other means), but how do i reference a particular index of a group?
I'm guessing other possible approaches include:
Plotting, one at a time (in a loop, using 'hold on'), the elements from each group - incrementally add (indexes of a group) to the bar plot with different color characteristics
otherwise stated - take element 1 from each of the groups and plot, take element 2 from each of the groups and plot, etc....
Or, plotting whole groups and then adding groups that have already been colored appropriately?
...but I can't get either of these to work.
Can anyone help me? Pleeeeeaaaaaaase!
Thanks, Kyle Stanhouse

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!