how to constrain a 3d plot within a panel

1 回表示 (過去 30 日間)
Salvatore
Salvatore 2013 年 12 月 14 日
回答済み: Salvatore 2014 年 5 月 10 日
Hi,
how to constrain a plot (associated to an axes) within a panel?
If I try to zoom-in the plot extends over the whole figure.
Here's the simple code.
Thanks in advance
Salvatore
h = figure('Units', 'normalized', 'Color', [.9 .9 .9], 'Position', [.15 .15 .7 .6],...
'menubar','figure','toolbar','figure');
fp3d=uipanel('Parent', h, 'Position', [.4 .32 .6 .68]);
fp2d=uipanel('Parent', h, 'Position', [.4 .001 .6 .3]);
ha3d = axes('Parent', fp3d,'Units', 'normalized','Position', [0.1 0.1 .8 .8]);
ha2d = axes('Parent', fp2d,'Units', 'normalized','Position', [0.1 0.2 .8 .7]);
set(h,'CurrentAxes',ha3d)
% axes(ha3d)
[x,y] = meshgrid([-2:.2:2]);
Z = x.*exp(-x.^2-y.^2);
surf(x,y,Z,gradient(Z))
colorbar
set(h,'CurrentAxes',ha2d)
% axes(ha2d)
xx=0:.1:pi;
yy=sin(xx);
plot(xx,yy)

回答 (4 件)

Walter Roberson
Walter Roberson 2013 年 12 月 15 日
Set the 'Clipping' property of the uipanel to be 'on'.

Salvatore
Salvatore 2013 年 12 月 15 日
編集済み: Walter Roberson 2013 年 12 月 15 日
Thanks Walter
but the problem still remains.
fp3d=uipanel('Parent', h, 'Position', [.4 .32 .6 .68],'Clipping', 'on');
fp2d=uipanel('Parent', h, 'Position', [.4 .001 .6 .3],'Clipping', 'on');
Look at the attached pictures.
Any suggestion?
Regards
Salvatore

Rony
Rony 2014 年 5 月 7 日
Hey Salvatore,
It seems that this is a popular problem with uipanel.
Were you able to solve it?
Regards, Rony

Salvatore
Salvatore 2014 年 5 月 10 日
Hi Rony unfortunately, this issue is a known bug and I know developers are working on it, so it will be fixed in a future release.
A possible workaround (suggested by mathworks support) is to change the axes limits instead of zooming. The following example shows you how to zoom the peaks surface within 0 and 25 on x and y axes:
ax2=subplot(2,1,2); surf(peaks)
ax1=subplot(2,1,1); surf(peaks)
set(ax1,'xlim',[0 25],'ylim',[0 25],'zlim',[-5 5])
My suggestion is to work with separate figures for each plot you need to handle.
Regards
Salvatore

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by