Azzera filtri
Azzera filtri

How to link axes on colormap?

17 visualizzazioni (ultimi 30 giorni)
Emilia Butters
Emilia Butters il 25 Giu 2023
Risposto: Parth Saraf il 25 Giu 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');

Risposte (1)

Parth Saraf
Parth Saraf il 25 Giu 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!!

Categorie

Scopri di più su Graphics Objects in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by