Legend for a patches object
Ältere Kommentare anzeigen
From the Patches help page, I have made a graphic showing the FOV for a set of sensors. I have used the 'unique color' row in the face-coloring table. I included a screen grab of the section of the document. My question is, now that I have coloring for each face, I need to add a legend entry for each color. However, the patch is one graph object, or it seems like it. That is, I can only display 1 legend entry because there is only 1 patch. How can I populate the legend with all of the items I want.
1 Kommentar
Star Strider
am 28 Jul. 2015
We don’t have your graphic or your code. This makes it extremely difficult to provide you any sort of definitive help.
Antworten (2)
Kelly Kearney
am 28 Jul. 2015
I usually create placeholder single-color patches to use for labeling purposes:
% A multi-faceted patch, one color per face
x = [2 5; 2 5; 8 8];
y = [4 0; 8 2; 4 0];
c = [0 1];
h = patch(x,y,c);
% Placeholder patches
unqc = unique(c);
label = cellstr(num2str(unqc'));
hold on;
for il = 1:length(unqc)
hl(il) = patch(NaN, NaN, unqc(il));
end
% Legend
legend(hl,label);
Nolan
am 28 Jul. 2015
1 Kommentar
Kelly Kearney
am 28 Jul. 2015
Your example doesn't quite run correctly... mismatched sizes in you x/yData vs cdata. Are you trying to assign one color per face? If so, the range of the colormap is irrelevant, as long as you set up your dummy patches using the same mapping.
Kategorien
Mehr zu Color and Styling finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!