Effacer les filtres
Effacer les filtres

How to link axes on colormap?

17 vues (au cours des 30 derniers jours)
Emilia Butters
Emilia Butters le 25 Juin 2023
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');

Réponses (1)

Parth Saraf
Parth Saraf le 25 Juin 2023
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!!

Catégories

En savoir plus sur Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by