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 CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by