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 Kommentare

Walter Roberson
Walter Roberson am 27 Mai 2020
What kind of graphic object are those for? Were you using rectangle() ? Or bar() ?
sani
sani am 27 Mai 2020
histograms (I'm ploting multiple signals from a detector)

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

darova
darova am 27 Mai 2020

1 Stimme

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 Kommentare

sani
sani am 28 Mai 2020
wierd, I can see in your picture it is filled, but when I'm running it, it is hollow
darova
darova am 28 Mai 2020
Maybe you have newer version and there some some difference in handlers
Try to experiment with these
sani
sani am 28 Mai 2020
great,will do!
thanks again!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 27 Mai 2020

Kommentiert:

am 28 Mai 2020

Community Treasure Hunt

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

Start Hunting!

Translated by