How to make widths of all subplot and colorbars same?
Show older comments
Following is my figure code. However, the size of subplots and colorbars are not same. How can I edit the following code to make all the subplots colorbars of same width. With following figure size, the x labels are appearing half below the figure boundary Can I also shift plots a little bit up?
figure,subplot(131); imagesc([3:0.01:11], time, Prob_ip0); hold on;
plot(ip0_m,time,'k','linewidth', 1.2); xlabel('I_P (km s^-1. kg m-3)');
axis([3 11 2000 2200]); set(gca,'ytick',[2000:40:2200]);
set(gca,'xtick',[3:4:11]); set(gca,'FontSize',11); grid on;
ylabel('Time (sec)'); colorbar; caxis([0 0.0061]);
subplot(132); imagesc([0.4:0.01:7], time, Prob_is0); hold on;
plot(is0_m,time,'k','linewidth', 1.2); xlabel('I_S (km s^-1. kg m-3');
axis([0.4 7 2000 2200]); set(gca,'ytick',[]); % set(gca,'ytick',[2000:40:2200]);
set(gca,'xtick',[0.4:3.5:7]); set(gca,'FontSize',11); grid on;
ylabel('Time (sec.)'); ylabel([]); colorbar; caxis([0 0.0076]);
subplot(133); imagesc([2.000:0.0010:2.600], time, Prob_rho0); hold on;
plot(rho0_m,time,'k','linewidth', 1.2); set(gca,'FontSize',11);
ylabel('Time (sec)'); ylabel([]); set(gca,'ytick',[]); %set(gca,'ytick',[2000:40:2200]);
xlabel('Rho (kg/m^3)'); set(gca,'xtick',[2.000:0.3:2.600]); grid on;
colorbar; colormap(flipud(jet)); caxis([0 0.0082]);
set(gcf, 'position', [500 285 800 410]);
5 Comments
Matt J
on 10 Feb 2024
Running the code results in errors, see above.
Ahmed
on 10 Feb 2024
Nope. It still doesn't run.
time=(1:116)';
figure,subplot(131); imagesc([3:0.01:11], time, Prob_ip0); hold on;
plot(ip0_m,time,'k','linewidth', 1.2); xlabel('I_P (km s^-1. kg m-3)');
axis([3 11 2000 2200]); set(gca,'ytick',[2000:40:2200]);
set(gca,'xtick',[3:4:11]); set(gca,'FontSize',11); grid on;
ylabel('Time (sec)'); colorbar; caxis([0 0.0061]);
subplot(132); imagesc([0.4:0.01:7], time, Prob_is0); hold on;
plot(is0_m,time,'k','linewidth', 1.2); xlabel('I_S (km s^-1. kg m-3');
axis([0.4 7 2000 2200]); set(gca,'ytick',[]); % set(gca,'ytick',[2000:40:2200]);
set(gca,'xtick',[0.4:3.5:7]); set(gca,'FontSize',11); grid on;
ylabel('Time (sec.)'); ylabel([]); colorbar; caxis([0 0.0076]);
subplot(133); imagesc([2.000:0.0010:2.600], time, Prob_rho0); hold on;
plot(rho0_m,time,'k','linewidth', 1.2); set(gca,'FontSize',11);
ylabel('Time (sec)'); ylabel([]); set(gca,'ytick',[]); %set(gca,'ytick',[2000:40:2200]);
xlabel('Rho (kg/m^3)'); set(gca,'xtick',[2.000:0.3:2.600]); grid on;
colorbar; colormap(flipud(jet)); caxis([0 0.0082]);
set(gcf, 'position', [500 285 800 410]);
Matt J
on 10 Feb 2024
The more usual thing to do in this forum would be for you to run it for us, and explicitly demonstrate the problem.
Ahmed
on 11 Feb 2024
Accepted Answer
More Answers (0)
Categories
Find more on Subplots 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!

