필터 지우기
필터 지우기

Subplot of Contour Plot figures

조회 수: 21 (최근 30일)
Cakil
Cakil 2023년 4월 16일
댓글: Walter Roberson 2023년 4월 17일
Dear Matlab Community,
I try to subplot my three figures but the output looks very different. I also can not see the color bar.
My each figure look like the below figure
However the result of subplot is very different than actual.
Maybe my figures are too heavy for this command? Does it effect the output of the function?
I am using this script to basicly open them and merge them in one figure:
fig1 = openfig('fig1.fig');
fig2 = openfig('fig2.fig');
fig3 = openfig('fig3.fig');
figure;
subplot(3,1,1)
copyobj(get(findobj(fig1,'Type','Axes'),'Children'),gca);
title('Figure 1')
axis equal;
axis tight;
subplot(3,1,2)
copyobj(get(findobj(fig2,'Type','Axes'),'Children'),gca);
title('Figure 2')
axis equal;
axis tight;
subplot(3,1,3)
copyobj(get(findobj(fig3,'Type','Axes'),'Children'),gca);
title('Figure 3')
axis equal;
axis tight;
% Close the original figures
close(fig1);
close(fig2);
close(fig3);
Thank you in advance for your time.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 4월 16일
Historically there could only be one colormap per figure and it was stored as a property of the figure
Eventually MATLAB added the possibility of a color map per axes -- but the default colormap() call still manipulates the figure colormap. You would have to colormap(AXES, MAP) to apply the colormap to the axes instead of the figure.
So at least one of the problems you are having is that you are not copying the figure colormap to be the colormap of the subplot axes.
Historically, colorbar() used to be implemented as a separate axes, but that was eventually changed to be a separate graphics object type that is "associated" with an axes. I have typically seen the newer colorbar objects copied when the axes is copied, but I don't think that is certain.
You might need to copyobj() the colorbar object as well... except I am not sure of exactly which parent object you should give it. It might be easier to find the colorbar object in the source figure and copy its properties onto a newly created colorbar() object.
  댓글 수: 2
Cakil
Cakil 2023년 4월 17일
Dear @Walter Roberson, thank you for your support. I have updated my script with:
c = colorbar('peer', gca);
and now I can see my colorbars. However my contour plots still look very different than my actual figure. How can I fix the output of the subplot?
Thank you very much for your time.
Walter Roberson
Walter Roberson 2023년 4월 17일
Are you copying the colormap from the figure to the subplot axes?
Can you attach fig1.fig for testing?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by