Contours in GUI

1 回表示 (過去 30 日間)
armin
armin 2011 年 7 月 12 日
hi i want to show 2 contours in 1 axes in GUI But how???
thank u for u r answer

採用された回答

Walter Roberson
Walter Roberson 2011 年 7 月 12 日
Method #2.
I realized after I coded this that there was a better way of proceeding, but it was too good of code to go to waste ;-)
ch1 = contour(...);
chc1 = findobj(ch1,'-property','xdata');
minx1 = min(arrayfn(@(h) min(get(h,'xdata')),chc1));
maxx1 = max(arrayfun(@(h) max(get(h,'xdata')),chc1));
xoff = maxx1 + (maxx1 - minx1) * 1.1; %second plot after a 10% gap
hold on;
ch2 = contour(...);
chc2 = findobj(ch2,'-property','xdata');
minx2 = min(arrayfn(@(h) min(get(h,'xdata')),chc2));
xoff = xoff - minx2;
arrayfun(@(h) set(h, 'xdata', xoff + get(h,'xdata')), chc2);
See also the material about xlim and labels in Method #1
  2 件のコメント
armin
armin 2011 年 7 月 13 日
Thanks a billllllllllion for answer
armin
armin 2011 年 7 月 13 日
Thanks a billllllllllion for answer

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 7 月 12 日
Method #1:
If you "hold on" between contour plots then both will be plotted. If the X range for the two does not overlap then they will be plotted with a space between them. You can look at method #2 for some hints on how to insert a gap between the two, except you would apply the min() and max() to the original data variables instead of get()'ing them after the plot.
The trick after you have plotted the second plot is that you will have to change the x axis limit, xlim, to include the entire range: for whatever reason, the axis limits do not automatically expand to include the new data.
Note that for both of these methods, the x coordinate labels of the second graph will be messed up: if you need the x coordinate labels to be correct for both of them and the x coordinates of the two overlap, then it is not appropriate to plot everything on a single axes.

カテゴリ

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