フィルターのクリア

am able to zoom only last plot ,how to zoom other plots.please help

1 回表示 (過去 30 日間)
rafi abdul
rafi abdul 2013 年 2 月 7 日
Hi i have 3 plots in same figure,when i am zooming only last generated plot is zooming.how to select other plot individually and zoom when all other plots are displayed.here is my code,please help
x = 0:20;
N = numel(x);
y1 = rand(1,N);
y2 = 5.*rand(1,N)+5;
y3 = 50.*rand(1,N)-50;
%# Some initial computations:
axesPosition = [110 40 200 200]; %# Axes position, in pixels
yWidth = 30; %# y axes spacing, in pixels
xLimit = [min(x) max(x)]; %# Range of x values
xOffset = -yWidth*diff(xLimit)/axesPosition(3);
%# Create the figure and axes:
figure('Units','pixels','Position',[200 200 330 260]);
h1 = axes('Units','pixels','Position',axesPosition,...
'Color','w','XColor','k','YColor','r',...
'XLim',xLimit,'YLim',[0 1],'NextPlot','add');
h2 = axes('Units','pixels','Position',axesPosition+yWidth.*[-1 0 1 0],...
'Color','none','XColor','k','YColor','m',...
'XLim',xLimit+[xOffset 0],'YLim',[0 10],...
'XTick',[],'XTickLabel',[],'NextPlot','add');
h3 = axes('Units','pixels','Position',axesPosition+yWidth.*[-2 0 2 0],...
'Color','none','XColor','k','YColor','b',...
'XLim',xLimit+[2*xOffset 0],'YLim',[-50 50],...
'XTick',[],'XTickLabel',[],'NextPlot','add');
xlabel(h1,'time');
ylabel(h3,'values');
%# Plot the data:
plot1=plot(h1,x,y1,'r');
plot2=plot(h2,x,y2,'m');
plot3=plot(h3,x,y3,'b');

採用された回答

ChristianW
ChristianW 2013 年 2 月 7 日
The function setAllowAxesZoom will do the job. If you add this example to your code, you are zooming in axes h1.
hz = zoom;
setAllowAxesZoom(hz,h1,true)
setAllowAxesZoom(hz,h2,false)
setAllowAxesZoom(hz,h3,false)
If you dont want to change your code all the time you want to zoom, you can create a uicontrol, like this:
hz = zoom;
hax = [h1;h2;h3];
set(gcf,'Toolbar','figure')
uicontrol('Style', 'popup','String', 'red|magenta|blue',...
'Position',[120 243 50 20],'Callback',{@zoom_opt,hz,hax});
Since the uicontrol calls the zoom_opt function whenever its used, you'll need that function:
function zoom_opt(hObj,event,hz,hax)
% Called when user activates popup menu
val = get(hObj,'Value');
W = [0 0 0];
W(val) = 1;
for i = 1:3
setAllowAxesZoom(hz,hax(i),W(i))
end
zoom on
  5 件のコメント
rafi abdul
rafi abdul 2013 年 2 月 8 日
hi when i am zooming in x direction in specific range ,values are changing in x direction for red only ,when i select other tow colours and if i zoom in x direction x values are not getting changed.i want same action(change of values in selected range) for all the colours.how to proceed
ChristianW
ChristianW 2013 年 2 月 8 日
Delete last line in function zoom_opt. (zoom on)
This will change all axes to the zoomed Xlimits:
set(hz,'ActionPostCallback',{@mypostcallback,hax},'Enable','on');
function mypostcallback(obj,evd,hax)
newLim = get(evd.Axes,'XLim');
set(hax,'XLim',newLim)
Thats how its basicly done. Iam not building in your axes offsets.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by