How to set properly single colorbar for subplots?
Show older comments
Hi, As you see here, I need only one globar color bar for all the subplots. But when I try using this, the first two subplots are of one size and last one is of different size. How to resolve this issue?
% Sample data for the subplots
data1 = rand(10, 10);
data2 = rand(10, 10);
data3 = rand(10, 10);
% Set the default font size for all subplots in the figure
set(0, 'DefaultAxesFontSize', 20);
% Create a figure
figure;
% Create the first subplot
subplot(1, 3, 1);
imagesc(data1);
title('Subplot 1');
% Create the second subplot
subplot(1, 3, 2);
imagesc(data2);
title('Subplot 2');
subplot(1, 3, 3);
imagesc(data3);
title('Subplot 2');
% Create a color bar
cbar = colorbar;
cbar_title = 'Global Color Bar';
cbar.Label.String = cbar_title;
Accepted Answer
More Answers (0)
Categories
Find more on Color and Styling 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!
