Delete specific contour line from contour plot

35 ビュー (過去 30 日間)
Raees
Raees 2019 年 4 月 5 日
コメント済み: Raees 2019 年 4 月 5 日
I have made a contour plot, due to some reason unknown to me, there is one abnormality in the graph. One contour line is out of order, and I want to delete it. Kindly if someone can help or guide me to get rid of the contour line with ‘0’ markings. I am using the following code:
contour(X,Y,M,'ShowText','on');
here M is a matrix of size and X & Y are also matrices of same size and obtained as
[X,Y]=meshgrid(x,y);
Following is the output
Contour Plot.bmp
I am not an expert in MATLAB, maybe that's the reason I am unable to figure out the cause for the occurrence of this contour line. I’ve also attached the data matrix for this code.
Thanks a lot for your help.

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 4 月 5 日
It is not obvious to me which contour you want to remove, but if you don't want, for example the 0-level contour you do:
contour(X,Y,M,[0.1:0.1:1])
If it is some other contour you need to purge you might have to be a bit more hands-on:
[Qc,Hc] = contour(peaks(123));
Hcc = get(Hc,'children'); % Handles to the contour segments at least in my matlab-version
delete(Hcc(4)) % If the fourth contour-segment is the offending one...
HTH
  1 件のコメント
Raees
Raees 2019 年 4 月 5 日
Thanks a lot. It worked.

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2019 年 4 月 5 日
編集済み: KSSV 2019 年 4 月 5 日
You can read about the option of LevelList in the countour. YOu can provide only those levls which you want to plot. Read more in contour function.
In your case this should work:
contour(X,Y,M,'LevelList',0.1:0.1:9,'ShowText','on');
untitled.bmp
  1 件のコメント
Raees
Raees 2019 年 4 月 5 日
Thanks for your kind reply. The solution by Bjorn Gustavsson worked, and your suggestion was also worthy.
Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by