How to make one Colorbar for a 2x2 subplot

1 Ansicht (letzte 30 Tage)
Shan  Chu
Shan Chu am 13 Feb. 2020
Hi everyone,
I would like to make one Colorbar for a 2x2 subplot on right hand side. I have read the answer of a similar question: https://uk.mathworks.com/matlabcentral/answers/144453-how-to-make-one-colorbar-for-all-subplots
But I couldn't see the tick of the colorbar as well as the title. Could you please help?
Thanks
Here is my code:
subplot(2,2,1)
[C,h]=contour(f_mat,sig_mat,real(L_lossy_mat).'*1e9,'LineWidth',2);
h.LevelList = [-1 -0.5 -0.2 -0.05 0.0 0.03 0.04 0.05 0.06];
clabel(C,h,'LabelSpacing',100,'FontSize',14,'FontWeight','bold','FontSmoothing','on','Interpreter','Latex')
ylabel('$\sigma^{(\textbf{I})}$ (S/m)','Interpreter','Latex')
xlabel('$f$ (MHz)','Interpreter','Latex')
title('$R=\infty$','Interpreter','Latex','Color',[125/255 30/255 125/255])
ax=gca;
ax.YDir = 'reverse';
ax.YScale = 'log';
ax.YMinorGrid = 'off';
ax.TickLabelInterpreter = 'latex';
xticks([37 46 55])
yticks([0.01 0.1 1 10])
yticklabels({'0.01','0.1','1','10'})
subplot(2,2,2)
[C,h]=contour(f_cst,sig_cst,real(L_11_cst).'*1e9,'LineWidth',2);
h.LevelList = [-1 -0.5 -0.2 -0.05 0.0 0.03 0.04 0.05 0.06];
clabel(C,h,'LabelSpacing',100,'FontSize',14,'FontWeight','bold','FontSmoothing','on','Interpreter','Latex')
ylabel('$\sigma^{(\textbf{I})}$ (S/m)','Interpreter','Latex')
xlabel('$f$ (MHz)','Interpreter','Latex')
title('$R=1.1r_0$','Interpreter','Latex','Color',[125/255 30/255 125/255])
ax=gca;
ax.YDir = 'reverse';
ax.YScale = 'log';
ax.YMinorGrid = 'off';
ax.TickLabelInterpreter = 'latex';
xticks([37 46 55])
yticks([0.01 0.1 1 10])
yticklabels({'0.01','0.1','1','10'})
subplot(2,2,3)
[C,h]=contour(f_cst,sig_cst,real(L_20_cst).'*1e9,'LineWidth',2);
h.LevelList = [-1 -0.5 -0.2 -0.05 0.0 0.03 0.04 0.05 0.06];
clabel(C,h,'LabelSpacing',100,'FontSize',14,'FontWeight','bold','FontSmoothing','on','Interpreter','Latex')
ylabel('$\sigma^{(\textbf{I})}$ (S/m)','Interpreter','Latex')
xlabel('$f$ (MHz)','Interpreter','Latex')
title('$R=2r_0$','Interpreter','Latex','Color',[125/255 30/255 125/255])
ax=gca;
ax.YDir = 'reverse';
ax.YScale = 'log';
ax.YMinorGrid = 'off';
ax.TickLabelInterpreter = 'latex';
xticks([37 46 55])
yticks([0.01 0.1 1 10])
yticklabels({'0.01','0.1','1','10'})
subplot(2,2,4)
[C,h]=contour(f_cst,sig_cst,real(L_30_cst).'*1e9,'LineWidth',2);
h.LevelList = [-1 -0.5 -0.2 -0.05 0.0 0.03 0.04 0.05 0.06 0.08];
clabel(C,h,'LabelSpacing',200,'FontSize',14,'FontWeight','bold','FontSmoothing','on','Interpreter','Latex')
ylabel('$\sigma^{(\textbf{I})}$ (S/m)','Interpreter','Latex')
xlabel('$f$ (MHz)','Interpreter','Latex')
title('$R=3r_0$','Interpreter','Latex','Color',[125/255 30/255 125/255])
ax=gca;
ax.YDir = 'reverse';
ax.YScale = 'log';
ax.YMinorGrid = 'off';
ax.TickLabelInterpreter = 'latex';
xticks([37 46 55])
yticks([0.01 0.1 1 10])
yticklabels({'0.01','0.1','1','10'})
colormap(hsv(1000))
hp4 = get(subplot(2,2,4),'Position')
h = colorbar('Position', [hp4(1)+hp4(3)+0.02 hp4(2) 0.1 hp4(2)+hp4(3)*2.1]);
h.TickLabelInterpreter = 'latex';
caxis([-1.8 0.1])
ylabel(h, '$\rm{Re}\{\, \mathcal{L} \,\}$ (nH)','Interpreter','Latex')
set(gcf,'Color','w')
set(findall(gcf,'-property','FontName'),'fontsize',18)

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by