필터 지우기
필터 지우기

How to link axes on colormap?

조회 수: 17 (최근 30일)
Emilia Butters
Emilia Butters 2023년 6월 25일
답변: Parth Saraf 2023년 6월 25일
Hi,
I am trying to link the axes so that the two subplots share the same colourbar, I have tried using linkaxes(hAxis, 'x'), linkaxes(hAxis.CurrentAxis, 'x'). Can anyone help me please? The code is below:
hFig = gcf;
set(gcf,'Color','w','Units','Normalized');
for i = 1:nSubplot
subplot(1,nSubplot,i);
if isempty(xmin)
[hAxis, hPatch, hColorbar] = DOTHUB_plotSurfaceImage(rmap.gmSurfaceMesh,img(i,:),viewAng,shadingtype,varInputs.colormap);
else
[hAxis, hPatch, hColorbar] = DOTHUB_plotSurfaceImage(rmap.gmSurfaceMesh,img(i,:),viewAng,shadingtype,varInputs.colormap, xmin, xmax);
end
set(hAxis,'FontSize',16);
hColorbar.Location = 'South';
tmp = hColorbar.Position;
hColorbar.Position = [tmp(1) tmp(2) tmp(3) tmp(4)];
hColorbar.AxisLocation = 'out';
ylabel(hColorbar,subplotLabels{1,i})
end
% [~,fname,~] = fileparts(dotimg.fileName);
fname = filename;
linkaxes(axes,'x');

답변 (1개)

Parth Saraf
Parth Saraf 2023년 6월 25일
Hello Emilia,
I understood from your question that you are unable to link the axes. You may use the gca for current axes or chart
hAxis = gca;
linkaxes(gca, "xy", "color");
You may look at this documentation for further details:
Hope it helps!!

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by