Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Changing colors of stacked bar graph

Subject: Changing colors of stacked bar graph

From: Brendan

Date: 12 Aug, 2010 12:12:11

Message: 1 of 2

Hi. I'm trying to create a stacked bar graph but to change the colors of the bars from the default to something that's more legible for my needs. My problem is that I expect to have a bunch of zeros (so some bars won't show up) which means I need a more distinguishing color map.

Here is what I have countErrorType is what I want to create the stacked bar graph of, ColorOrder2 is what I want my bars to have their colors be

countErrorType=[0 0
         0 0
    0.2100 0.2250
    0.2800 0.3100
    0.0100 0.0100
         0 0
    0.1800 0.1700
         0 0
    0.1900 0.1900
    0.0300 0.0100
         0 0
    0.0750 0.0700
         0 0
    0.0250 0.0150
         0 0];

        ColorOrder2=[1 1 1;
                    0.5 1 0.5;
                    0 1 0;
                    0 0.5 0;
                    1 0.5 0.5;
                    1 0.2 0.2;
                    1 0 0;
                    0.8 0 0;
                    0.5 0 0;
                    0.5 0.5 1;
                    0.2 0.2 1;
                    0 0 1;
                    0 0 0.8;
                    0 0 0.5;
                    0 0 0];

h=bar(numSampArray,countErrorType','Stacked');


I tried following the shading example in the help file, but couldn't modify it to my needs.

Thank you for your help

Brendan

Subject: Changing colors of stacked bar graph

From: Brendan

Date: 12 Aug, 2010 21:03:06

Message: 2 of 2

For anyone else wondering, it's apparently really easy
just use

colormap(ColorOrder2)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us