Contour on a contourf plot

조회 수: 16 (최근 30일)
Ron Nativ
Ron Nativ 2020년 6월 25일
댓글: Ron Nativ 2020년 6월 25일
Hello all,
I would like to plot black contour lines of 'Zi2' matrix on a previously plotted contourd plot (swith the matrix Zi2). The problem is that when I use contour, the colours of the contourf plot are being deleted and only the contours are stayed. Can someone help? here is my code:
[c h]= contourf(Xi,Yi,Zi,'linew',1)
clabel(c,h)
hold on;
contour(Xi,Yi,Zi2,'k')
THe plotted figure is attached.
Thanks for your help!
Ron

채택된 답변

KSSV
KSSV 2020년 6월 25일
편집: KSSV 2020년 6월 25일
contourf gives you a colored plot. It fills the contour lines region with colors. To get whay you want use:
c = contour(Xi,Yi,Zi) ;
Now check, c has (x,y) coordinates. Now you can plot them using plot with required color.
plot(c(1,:),c(2,:),'k') ;
Or Striaght away, you can use contour ans specify the color.
contour(Xi,Yi,Zi,'k')
  댓글 수: 7
KSSV
KSSV 2020년 6월 25일
contour(Xi,Yi,Zi,'k')
Ron Nativ
Ron Nativ 2020년 6월 25일
Thanks! but this command runs over the filled contour (contourf) and deltes its colors from some reason

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by