How to keep Marker color unchanged
2 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
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
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.
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!