colormap problem. bar graph doesn`t respond to colormap command

조회 수: 15 (최근 30일)
Hayk Karapetyan
Hayk Karapetyan 2019년 3월 6일
댓글: Clay Fulcher 2020년 3월 29일
I use matlab 2018b version.
colormap option still works with bar3 graphs, but doesn`t work with bar graphs.
bar3(rand(5),'stacked')
colormap(cool)
bar(rand(5),'stacked')
colormap(cool)
is there an alternative way to set the colormap for bar graph?
  댓글 수: 3
Clay Fulcher
Clay Fulcher 2020년 3월 29일
I finally figured out how to get the colormap to respond. When you change the colormap, you now have to take an extra step to assign the sets of bars to rows in the colormap. Here is an example for a bar plot with 2 groups.
>> y=randn(6,2);
>> b=bar(y,'facecolor','flat');
>> for k=1:size(y,2)
b(k).CData=k;
end
>> colormap copper
Clunky, but it works. Mathworks made something complicated that used to be simple.

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 3월 27일
I just answered a similar question here. It is still possible, but it appears the way to do it has changed.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by