Freeze axis between successive plots?

3 views (last 30 days)
My humble script is starting to take shape. The problem occurs when I make one plot active (visible) and the other inactive (invisible). I plan to expand this to more than just these two plots. The following image documents what is happening :
As you'll see in the following code, I first display sRGB. And then, when the user selects a different entry in the drop-down list, I "toggle" to AdobeRGB.
global sRGBGamut AdobeRGBGamut ax;
figure;
ax=axes;
popup = uicontrol('Style', 'popup',...
'String', {'sRGB','AdobeRGB','P3','Rec2020'},...
'Position', [10 10 100 50],'background','green',...
'Value',1,'Callback',@popupCallback);
[r,g,b] = meshgrid(linspace(0,1,20)); % linspace(0,1,50)
rgb = [r(:), g(:), b(:)];
% lab sert d'Input à la conversion de profil ICC
lab = rgb2lab(rgb); % Input - double (0.0 à 1.0)
lab2 = rgb2lab(rgb,'ColorSpace','adobe-rgb-1998');
a = lab(:,2);
b = lab(:,3);
L = lab(:,1);
k = boundary(a,b,L);
sRGBGamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
xlabel('a*');
ylabel('b*');
zlabel('L*');
axis([-128 128 -128 128 0 100]);
view(10,35);
axis equal
title('sRGB gamut surface', 'in L*a*b* space'); % Add Title to Current Axes
ax.TitleHorizontalAlignment = 'left';
hold on
a = lab2(:,2);
b = lab2(:,3);
L = lab2(:,1);
k = boundary(a,b,L);
AdobeRGBGamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
%set(AdobeRGBGamut, 'Visible', 'off');
function popupCallback(popup,event)
sels = get(popup,'String');
idx = get(popup,'Value');
Selection = sels{idx};
global sRGBGamut;
global AdobeRGBGamut;
switch(Selection)
case 'sRGB'
title('sRGB gamut surface', 'in L*a*b* space');
set(AdobeRGBGamut, 'Visible', 'off');
set(sRGBGamut, 'Visible', 'on');
fprintf('sRGB\n' );
case 'AdobeRGB'
title('AdobeRGB gamut surface', 'in L*a*b* space');
set(sRGBGamut, 'Visible', 'off');
set(AdobeRGBGamut, 'Visible', 'on');
fprintf('AdobeRGB\n' );
case 'P3'
title('Display P3 gamut surface', 'in L*a*b* space');
set(sRGBGamut, 'Visible', 'off');
fprintf('P3\n' );
case 'Rec2020'
title('Rec2020 gamut surface', 'in L*a*b* space');
set(sRGBGamut, 'Visible', 'off');
fprintf('Rec2020\n' );
%otherwise
% fprintf('Invalid grade\n' );
end
end
Please feel free to comment on my program logic, by the way? I am sure I have a very naive approach to make this work in Matlab? Somehow, my code was not giving me satisfaction last night, before I went to bed. This morning? It seems to be working as expected.
So, the problem, in my view lies in the axis being regraphed (for lack of better word) instead of remaining constant. But I don't know what properties I need to activate in order for this to happen.

Accepted Answer

Roger Breton
Roger Breton on 15 Jan 2022
I removed the following statement :
axis equal
And that was it? This is the result :
The scales are constant, so the student can see that, what varies are the two gamuts.
I confess I never took any Matlab training of ny kind. I use what I find, here, and on the internet. I did try to look into the axis equal instruction before but confess it did not mean much to me, from reading the documentation?

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!