Contours in GUI
조회 수: 1 (최근 30일)
이전 댓글 표시
hi i want to show 2 contours in 1 axes in GUI But how???
thank u for u r answer
댓글 수: 0
채택된 답변
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
추가 답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!