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 日

0 投票

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 件のコメント

Ron Nativ
Ron Nativ 2020 年 6 月 25 日
Thanks for your answer KSSV. When using your solution, I then run into two problems: (1) the x and y axes are changed. When I use xlim and ylim to define them for the relevant limits, then I get wrong contours, see attached figure.
KSSV
KSSV 2020 年 6 月 25 日
It should work....did you try contour with black color specififed?
Ron Nativ
Ron Nativ 2020 年 6 月 25 日
ok I tracked the problem - I use your command but with 'scatter' instead of 'plot' and there are few point that should not be there and are currently there. I wonder how did they get there. They cause the wrong lines. See attached figure.
KSSV
KSSV 2020 年 6 月 25 日
Hey you can use contour with color option..this would be more simpler.
Ron Nativ
Ron Nativ 2020 年 6 月 25 日
what do you mean?
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 件)

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

タグ

質問済み:

2020 年 6 月 25 日

コメント済み:

2020 年 6 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by