How to add legend (or colorbar) to volshow/labelvolshow output?

18 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Voss
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
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?
Simone Cotta Ramusino
Simone Cotta Ramusino el 1 de Oct. de 2022
Attaching the whole process would be too cumbersome. Anyway, if you want to try, you can create sample E data like this:
E=ones(5,5,3);
E(1,:,:)=100000; % defining bg (far higher)
E(5,:,:)=100000;
E(:,1,:)=100000;
E(:,5,:)=100000;
E(2:4,2:4,1)=randi(100,3); % defining much lower values
E(2:4,2:4,2)=randi(100,3);
E(2:4,2:4,3)=randi(100,3);
and then use the visualization code I've attached before
tuttiE=E(:);
n_cluster=6; % and so on...
I've tried with this and I get the same problem so you can try too, if u want. Thanks again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by