How to keep Marker color unchanged

2 views (last 30 days)
User
User on 3 Mar 2015
Commented: Star Strider on 10 Mar 2015
I have following 5-line code ('Ln' indicates nth line in code)
L1 hist(ek_M);
L2 set(get(gca,'child'),'FaceColor','w','EdgeColor','b');
L3 hold on
L4 hist(absek_M)
L5 set(get(gca,'child'),'FaceColor','w','EdgeColor','r');
The problem is that when L5 is executed, the blue edge that was created with the execution of L3 is changed to red. How should I fix it?

Answers (1)

Star Strider
Star Strider on 4 Mar 2015
In L5 you told plot to change it to red:
set(get(gca,'child'),'FaceColor','w','EdgeColor','r');
The fix is obvious:
set(get(gca,'child'),'FaceColor','w','EdgeColor','b');
  2 Comments
User
User on 9 Mar 2015
In L1 and L4 plot different data, and I am superimposing the two to see how different they are. That is why I am using different colors for the two.
Star Strider
Star Strider on 10 Mar 2015
The hist function requires an interim step to change the colours of the bar faces and edges. See the hist documentation, specifically Specify Histogram Colors for details.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!