Add fixed colorbar to volshow
Show older comments
I have my code which is plotting results in a loop. I am visualizing them on the volumeviewer in 3D. for every frame in my loop there is a new figure and it updates accordingly.
my code is this:
%% Initialize volume visualization
% Define global color scale limits
globalMin = -1.5; % Minimum value across all frames
globalMax = 1.5; % Maximum value across all frames
% Normalize your volume for consistent color mapping
normalizedData = (compressed_hbt - globalMin) / (globalMax - globalMin);
normalizedData(normalizedData < 0) = 0; % Clamp values below 0
normalizedData(normalizedData > 1) = 1; % Clamp values above 1
% Use 256-color colormap
cmap = jet(256);
% Create volume viewer only once
if i == 1
% Create volume viewer with white background
vol_hbt = volshow(zeros(size(compressed_hbt)), ...
'Colormap', cmap, ...
'Alphamap', (linspace(0,0.7,256).^2));
end
% Update Volshow with normalized data
vol_hbt.Data = normalizedData;
% Keep the colorbar visible by forcing a refresh in the figure
drawnow;
but I want to insert a colorbar with values fixed into the volume viewer. I tried different approaches, but it won't show in the window. the axis can just be a fixed jet colorbar iwth constant ticks & a title. How can i realize this?
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Apr 2025
0 votes
You cannot do that. volshow() creates a standalone chart object.
There is an internal vol_hbt.Parent.Axes property but it is a images.ui.graphics.internal.Axes not a standard axes matlab.graphics.axis.Axes and cannot serve as the parent for a colorbar.
2 Comments
Lara
on 30 Apr 2025
Walter Roberson
on 30 Apr 2025
No, there is not. The vol_hbt.Parent.Axes object does not even have a Children property
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!