Legend for tiled donut charts
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Andrea Costantino
 il 28 Gen 2025
  
    
    
    
    
    Risposto: Andrea Costantino
 il 29 Gen 2025
            I have a 2x3 tiled layout.
In the first row, I put three donut charts (one per each "cell"). The figure is attached.
What I want to do is to put a unique legend for them in the whole second row. I saw that this is possible for other types of charts and interesting options were suggested to other users. The main problem is that the properties for the legend of donut charts are very limited.
Suggestions?
Thank you!

0 Commenti
Risposta accettata
  Voss
      
      
 il 28 Gen 2025
        Here's something that may help.
n = 3;
data = rand(10,n);
f = figure();
tl = tiledlayout(2,n);
d = gobjects(n,1);
for ii = 1:n
    nexttile(tl)
    d(ii) = donutchart(data(:,ii));
end
tl = tiledlayout(tl,1,1);
tl.Layout.Tile = n+1;
tl.Layout.TileSpan = [1,n];
ax = nexttile(tl);
ax.Visible = 'off';
c = d(1).ColorOrder;
nc = size(c,1);
nd = numel(d(1).Data);
c = repmat(c,ceil(nd/nc),1);
p = cellfun(@(x)patch(ax,NaN,NaN,x),num2cell(c(1:nd,:),2));
set(p,'FaceAlpha',d(1).FaceAlpha);
d(1).LabelsMode = 'manual';
d(1).Names = "slice "+(1:nd);
legend(p,d(1).Names,'Orientation','horizontal','NumColumns',ceil(nd/2));
0 Commenti
Più risposte (1)
Vedere anche
Categorie
				Scopri di più su Legend in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


