필터 지우기
필터 지우기

fill legend rectangles with color

조회 수: 5 (최근 30일)
sani
sani 2020년 5월 27일
댓글: sani 2020년 5월 28일
hello,
I'd like to fill the legend rectangles in color (not just the frame as in the picture), how it can be done?
thanks!
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 5월 27일
What kind of graphic object are those for? Were you using rectangle() ? Or bar() ?
sani
sani 2020년 5월 27일
histograms (I'm ploting multiple signals from a detector)

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

채택된 답변

darova
darova 2020년 5월 27일
Try this example
surf(peaks,'facecolor','none') % plot peaks
surface(membrane,'facecolor','none') % plot membrane
h = legend('surf','memb'); % show legend
h1 = get(h,'children'); % get handle of each object in legend
for i = 1:length(h1) % loop through each object
if strcmp(get(h1(i),'type'),'patch')% if an object is a patch
cc = get(h1(i),'edgecolor'); % get edgecolor
set(h1(i),'facecolor',cc) % set facecolor
end
end
  댓글 수: 3
darova
darova 2020년 5월 28일
Maybe you have newer version and there some some difference in handlers
Try to experiment with these
sani
sani 2020년 5월 28일
great,will do!
thanks again!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by