Can I use colormap to set color of my cumulative area chart in area()?
4 views (last 30 days)
Show older comments
If so, how should I use it?
I tried to put something like colormap(map) on some different places but they just didn't work.
2 Comments
Jeffrey Clark
on 30 Nov 2022
@稚萌 王, all questions should include what you have done so far so that we have some idea of what the question is. Attach code (.m) and data files (.txt, .csv, .mat etc) or at least the portion of code in a "Insert a line of code" box and error message like:
%code example
this = ~does %work
Unrecognized function or variable 'does'.
Answers (1)
Voss
on 1 Dec 2022
Edited: Voss
on 1 Dec 2022
area dioesn''t use the figure's colormap directly, but it does use the axes' ''ColorOrder' by default, so maybe something like this is what you want to do:
a = [1;2;3;4;5];
b = 2*a;
c = 3*a;
data = [a,b,c];
x_axis = 1:size(a,1);
area(x_axis,data,0);
set(gca(),'ColorOrder',summer(size(data,2)));
legend('a','b','c')
0 Comments
See Also
Categories
Find more on Red 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!