Contours in GUI

3 views (last 30 days)
armin
armin on 12 Jul 2011
hi i want to show 2 contours in 1 axes in GUI But how???
thank u for u r answer

Accepted Answer

Walter Roberson
Walter Roberson on 12 Jul 2011
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 Comments
armin
armin on 13 Jul 2011
Thanks a billllllllllion for answer
armin
armin on 13 Jul 2011
Thanks a billllllllllion for answer

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 12 Jul 2011
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.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!