How to label the levels of a fcontour plot?

39 ビュー (過去 30 日間)
TS
TS 2017 年 4 月 14 日
コメント済み: Star Strider 2017 年 4 月 15 日
How to label the levels of a fcontour plot? fcontour does not work with clabel nor has a option such as 'ShowText','on' in contour.

採用された回答

Star Strider
Star Strider 2017 年 4 月 14 日
You must use the contour function to get the contour labels.
Combining fcontour and contour to get the result you want (in figure(2) here) is not difficult. You first need to get the data fcontour creates. You can do that by returning the handle to it, and then accessing its properties.
Using an example from the documentation for fcontour and adapting it to use contour:
syms f(x,y)
f(x,y) = sin(x) + cos(y);
figure(1)
hfc = fcontour(f);
figure(2)
contour(hfc.XData, hfc.YData, hfc.ZData, 'ShowText','on')
Although this takes one more line of code, it will give you the result you want.
  2 件のコメント
TS
TS 2017 年 4 月 15 日
Thanks for this work arround. Im going to use this for now, but is there no more "elegant" way considering fcontour is pretty much the same function as contour (yet for symbolic). Espacially considering that im opening a dummy figure only to generate the data and dont use it (figure 1). It seems very odd to me that fcontour doenst have "showtext" itself.
Star Strider
Star Strider 2017 年 4 月 15 日
My pleasure.
The two functions have some significant differences. The outputs from fcontour are matrices, while the outputs from contour are the the vectors of (x,y) coordinates for each contour.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by