How to put separate titles above multiple pcolor subplots
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi all,
I have a figure of two subplots with pcolor-images. Now I want a separate title above each subplots, but somehow this doesn't work. I don't get an error, but the titles don't show. Anyone an idea how to fix this? Here is my code:
% Plot final modulus image comparison
fig = figure;
set(gcf, 'Position', [50, 100, 1200, 400])
fig_filename = 'final_modulus_map';
ax_min = min([ref_model.mod_img(:); opt_model_k.mod_img(:)]);
ax_max = max([ref_model.mod_img(:); opt_model_k.mod_img(:)]);
subplot(1,2,1);
h=pcolor(ref_model.mod_img);
colormap(hot)
set(h, 'EdgeColor', 'none');
set(gca,'visible','off');
c = colorbar;
set(gca,'ColorScale','log')
caxis([ax_min ax_max])
c.Label.String = 'Modulus (Pa)';
title('Ref_model_modulus');
subplot(1,2,2);
h=pcolor(opt_model_k.mod_img);
colormap(hot)
set(h, 'EdgeColor', 'none');
set(gca,'visible','off');
c = colorbar;
set(gca,'ColorScale','log')
caxis([ax_min ax_max])
c.Label.String = 'Modulus (Pa)';
title('Opt_model_modulus');
drawnow;
saveas(fig,fullfile([result_folder,'\1_modulus_maps'],fig_filename),'png')
댓글 수: 0
채택된 답변
Constantino Carlos Reyes-Aldasoro
2021년 2월 2일
The issue is that you are setting the axis to off with this
set(gca,'visible','off');
Your problem will be solved if you use
set(gca,'visible','on');
Notice that the title will be interpreted as a latex string, so the _ will convert the text. To avoid this you can use
title('Ref_model_modulus','interpreter','none');
Problem solved?
댓글 수: 3
Constantino Carlos Reyes-Aldasoro
2021년 2월 8일
You can always insert other objects, but setting to visible would be the easiest. If what you do not want is the ticks on the axes themselves, you can remove those texts in particular easily like this:
>> set(gca,'xtick',[])
>> set(gca,'ytick',[])
Hope this solves the question, if it does, please accept the answer. If it does not, do let me know.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Title에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!