How can I draw a contour line in contourf around "threshold" value

64 ビュー (過去 30 日間)
Lukas
Lukas 2013 年 7 月 13 日
編集済み: Kuifeng 2013 年 10 月 11 日
Hi all, I am pretty new to Matlab and have the following problem: In my contourf plot I would really like to draw a contour line around areas that include values above a specified threshold value (in my case: 0.9999). I am visualizing simulated fidelities. Here is the code I use to generate my plots:
figure(fig);
[C,h] = contourf(yplot, x, Zplot, 120);shading flat;%, 'LineStyle', 'none');shading flat;
kids = get(h,'children');
indices = cell2mat(get(kids,'Userdata')) > 0.8;
set(kids(indices),'linewidth',3);
t = colorbar('location','EastOutside','CLim',[0.5,1]);
set(get(t,'ylabel'),'String','Treue $\Phi$','FontSize',20);
xlabel('Startwert \epsilon_0 [GHz]','FontName','Timesnewroman','FontSize',20);
ylabel('Gatterzeit[ns]','FontName','Timesnewroman','FontSize',20);
And here is how the output looks like: http://s14.directupload.net/images/130713/q9zer5i3.jpg The part with "kids = ..." etc is taken from a thread that deals with an almost identical question http://www.mathworks.com/matlabcentral/answers/43787 but somehow that does not work in my case. Just copying from the linked thread works fine, but not for my own plots...
I hope that I made an understandable description for my problem! I would really appreciate some help.
Thanks in advance, Luk
Edit: Just noticed a stupid mistake... The "shading flat" line seems to surpress the line(s) to be drawn. Nevertheless if I remove "shading flat" it seems that there is not enough precision to find values that are >0.999. But such values are definitely inside my Zplot matrix - as I can see by using max(Zplot). It is also confusing that my colorbar goes only to slightly over 0.95 even though I set its maximum to 1 as there are a lot more values above 0.95 which need to be distinguished precisely.

回答 (1 件)

Kuifeng
Kuifeng 2013 年 10 月 11 日
編集済み: Kuifeng 2013 年 10 月 11 日
Try:
contourf(X, Y, Data, [0.9999 0.9999] )
Quote "To display a single contour line at a particular value, define v as a two-element vector with both elements equal to the desired contour level. For example, to draw a single contour of level i, use contourf(Z,[i i])"
Option 2:
hold on
contourf(X, Y, Data, [0.9999 0.9999], 'linestyle', 'none')
contour(X, Y, Data, [0.9999 0.9999] , 'linecolor', 'k')

カテゴリ

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