How to add legend (or colorbar) to volshow/labelvolshow output?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Simone Cotta Ramusino
el 25 de Mayo de 2022
Comentada: Simone Cotta Ramusino
el 1 de Oct. de 2022
Hi, can someone help me to add a legend to a panel created by labelvolshow? I managed to add a title but I really don't know how to put a legend (or at least a colorbar, even if I know it wouldn't be the same thing). Any kind of "legend" is accept: I mean, not just the output of the classic legend function; also some strings, written in the color of the data, can be fine for example..any way to categorize the output is welcome, the important thing is that I'd like it to be automatically generated by the code - no interactions with the panel required.
This is how I add a title:
view_panel = uipanel(figure,'Title',"Titolo");
view_panel.FontSize=14;
view_panel.TitlePosition='centertop';
labelvolshow(volume_labeled,'Parent',view_panel);
Thanks in advance
0 comentarios
Respuesta aceptada
Voss
el 25 de Mayo de 2022
Maybe something like this can be a start:
volume_labeled = randi(10,[5 5 5]);
view_panel = uipanel(figure,'Title',"Titolo");
view_panel.FontSize=14;
view_panel.TitlePosition='centertop';
h = labelvolshow(volume_labeled,'Parent',view_panel);
NC = size(h.LabelColor,1);
ax = axes( ...
'Parent',view_panel, ...
'Units','normalized', ...
'Position',[0.93 0 0.07 1], ...
'Visible','off', ...
'YLim',[0 10], ...
'CLim',[0 10], ...
'Colormap',h.LabelColor);
p = patch( ...
'Parent',ax, ...
'XData',repmat([0; 1; 1; 0],1,NC), ...
'YData',[0;0;1;1]+(0:NC-1), ...
'FaceColor','flat', ...
'FaceVertexCData',ax.Colormap);
t = text(ax,0.5*ones(1,NC),(1:NC)-0.5,sprintfc('%d',1:NC), ...
'HorizontalAlignment','center');
t(1).Color = [1 1 1];
17 comentarios
Walter Roberson
el 30 de Sept. de 2022
unfortunately I do not seem to replicate this with a minimal test. Would it be possible for you to attach data and enough code to reproduce the problem?
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!