Adding two shared colorbars to figures of tiledlayout
Show older comments
Hi guys
I want to add two different colorbars to figures of tiledlayout function. I have searched the community and find something similar on https://www.mathworks.com/matlabcentral/answers/194554-how-can-i-use-and-display-two-different-colormaps-on-the-same-figure but it doesn't seem to work along with tiledlayout function. There are two main problems:
- The same colorbar is assigned to both data.
- I want two shared colorbars ploted on either side of the final tiledlayout figure, but only one of them remain.
The code along with necessary mat files as a zip file are attached.
Any help would be greatly appreciated.
clc, clear, close all
% load mat files.
load('StCoords.mat')
load('KGE_EachSt.mat')
load('x.mat')
load('y.mat')
load('Values.mat')
tiledlayout('flow')
PointsMinValue = min(KGE_EachSt(:));
PointsMaxValue = max(KGE_EachSt(:));
DemMinValue = min(Values(:));
DemMaxValue = max(Values(:));
for i = 1:size(KGE_EachSt, 2)
nexttile
% Underlying layer.
imagesc(x, y, Values);
Dem = gca;
% Specifying colorbar limits.
caxis(Dem, [DemMinValue DemMaxValue])
% Specifying colorbar style.
colormap(Dem, 'cool')
axis xy
axis image
hold on
% Overlaying layer.
scatter(StCoords(:,2), StCoords(:,3), 20, KGE_EachSt(:,i), 'filled');
Points = gca;
% Specifying colorbar limits.
caxis(Points, [PointsMinValue PointsMaxValue])
% Specifying colorbar style.
colormap(Points, 'hot')
end
% Colorbar of points.
C = colorbar(Points);
C.Label.FontSize = 10;
C.Label.FontWeight = 'bold';
C.Layout.Tile = 'East';
% Colorbar of Dem.
C1 = colorbar(Dem);
C1.Label.FontSize = 10;
C1.Label.FontWeight = 'bold';
C1.Layout.Tile = 'West';
Accepted Answer
More Answers (0)
Categories
Find more on Orange in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


