The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Legend problem in bar graph
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Kate J.

Posts: 177
Registered: 6/9/11
Legend problem in bar graph
Posted: Dec 11, 2012 3:19 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

My code below successfully creates a bar plot that contains 5 bars, each with a unique color:

bar_h = bar(myData);
mycolor=[0 0 0;
1 0 0;
1 0 1;
1 1 0;
0 1 0];
index = [1 2 3 4 5];
set(bar_child, 'CData',index);
hold on;
h2 = errorbar(myData, myDataErrors);

However, I'm having problems with adding a legend; using the format


always results in the following behavior:
~ the first label appears correctly, with the correctly-colored box next to it
~ the second label's name appears, but there is no colored box next to it
~ the other 3 labels are missing from the legend

If I insert the handle name as the first argument to the legend() call, the behavior only worsens, now additionally eliminating the second label from the legend, as well...

Is anyone familiar with what I'm doing wrong? Thanks in advance for any advice.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.