Make a contourf plot beautifuller

조회 수: 2 (최근 30일)
Steffen B.
Steffen B. 2024년 1월 19일
댓글: Star Strider 2024년 1월 22일
Hello,
I have a question regarding the contourf plot in Matlab.
With my script:
f=figure(2);
fontSize=20;
f.Position(3:4)=[1280 1080];
%
contourf(x,y,T,15)
clabel(contourf(x,y,T,15,"-b"),'FontSize', fontSize)
cb= colorbar;
c=turbo(20);
colormap(c);
shading interp
set(gca,'ydir','reverse')
set(gca,'FontSize',fontSize)
set(cb,'FontSize',fontSize)
set(gca,'FontSize',fontSize)
xlabel('X/ m','FontSize', fontSize)
ylabel('Y/ m','FontSize', fontSize)
I get this plot:
It's not beaufifull.
I would like create something like this:
Is it possible to smooth the contourf plot to create a better plot?
Would it be also possible to achive a plot without filled areas, only with colored isolines? Like this:
With best regards
Steffen

채택된 답변

Star Strider
Star Strider 2024년 1월 19일
편집: Star Strider 2024년 1월 19일
The first one (with or without contour lines) is possible with a combination of the surf and view functions —
[X,Y,Z] = peaks(50);
figure
surf(X, Y, Z)
shading('interp')
view(0, 90)
The second is simply a contour plot —
figure
contour(X, Y, Z, 'LineWidth',1.5)
Ax = gca;
Ax.Color = [1 1 1]*0.7;
Combining them —
Zoffset = 2;
figure
surf(X, Y, Z)
shading('interp')
hold on
contour3(X, Y, Z+Zoffset, 'LineWidth',2)
hold off
view(0, 90)
EDIT — Corrected Errors.
.
  댓글 수: 2
Steffen B.
Steffen B. 2024년 1월 22일
Thanks,
that helped me a lot.
Star Strider
Star Strider 2024년 1월 22일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by