Thread Subject: Zoom / Camera Control in subplot

Subject: Zoom / Camera Control in subplot

From: Ben

Date: 17 Sep, 2007 22:02:13

Message: 1 of 9

I have a GUI with one main plot axes (3-D) axes with a
couple small plots(2-D) and a few text boxes of data next to
it. My problem is that I need to Zoom in on a specific area
of the 3-D plot. However, I can not zoom in on the main
plot without the axes becoming larger than it was originally
defined as and overtaking the smaller plots.
I have tried using the camera commands (campos, camtarget,
va, ect.) and zoom and view commands. But when I zoom in on
the area I need it ends up dominating the entire figure window.

Is there a way to contain the axes so that it is limited to
only the position[l,b,w,h].

Any help or suggestions would be appreciated. I can provide
an example if needed.

Thanks

Subject: Zoom / Camera Control in subplot

From: Ben

Date: 18 Sep, 2007 14:51:37

Message: 2 of 9

Here is an example. When the last line is executed the
second plot becomes to large and overlaps the top axis.
What I would like is for it zoom in on a region of the 3-d
plot, keeping the axes size/position the same. Not make the
axes larger. The only way I have been able to make this work
is to actually make a second figure and place it over the
first. There has to be a better way

% --------------
hfig = figure('Position',[200 200 800 600]);
hax1 = axes('Position',[0.1 0.6 0.8 0.3]);
plot([0:.1:10],sin([0:.1:10]));
hax2 = axes('Position',[0.3 0.1 0.4 0.4]);
[x,y,z] = sphere(24)
axes(hax2);surf(x,y,z,'FaceColor',[0 0.2 0.8])
axis vis3d
%Now try to zoom on the sphere it takes over the plot
camzoom(hax2,3)
% --------------

Thanks.

Subject: Zoom / Camera Control in subplot

From: Adam

Date: 19 Sep, 2007 12:05:04

Message: 3 of 9

"Ben " <basburywvu.nospam@hotmial.com> wrote in message
<fcoolp$llv$1@fred.mathworks.com>...
> Here is an example. When the last line is executed the
> second plot becomes to large and overlaps the top axis.
> What I would like is for it zoom in on a region of the 3-d
> plot, keeping the axes size/position the same. Not make the
> axes larger. The only way I have been able to make this work
> is to actually make a second figure and place it over the
> first. There has to be a better way
>
> % --------------
> hfig = figure('Position',[200 200 800 600]);
> hax1 = axes('Position',[0.1 0.6 0.8 0.3]);
> plot([0:.1:10],sin([0:.1:10]));
> hax2 = axes('Position',[0.3 0.1 0.4 0.4]);
> [x,y,z] = sphere(24)
> axes(hax2);surf(x,y,z,'FaceColor',[0 0.2 0.8])
> axis vis3d
> %Now try to zoom on the sphere it takes over the plot
> camzoom(hax2,3)
> % --------------
>
> Thanks.

Interesting. If your data is of the form z = f(x, y) you
may have to manually clip your data.

Two dockable figures may be sufficient?

hfig = figure('WindowStyle', 'docked');
plot([0:.1:10],sin([0:.1:10]));

hfig2 = figure('WindowStyle', 'docked')
hax2 = axes;
[x,y,z] = sphere(24);
axes(hax2);surf(x,y,z,'FaceColor',[0 0.2 0.8])
axis vis3d

Clicking "Top/Bottom Tile" in the top right gives a similar
layout.

~Adam

Subject: Zoom / Camera Control in subplot

From: Ben

Date: 19 Sep, 2007 19:13:16

Message: 4 of 9

"Adam " <not.my.email@mathworks.com> wrote in message >
> Interesting. If your data is of the form z = f(x, y) you
> may have to manually clip your data.
>
> Two dockable figures may be sufficient?
>
> hfig = figure('WindowStyle', 'docked');
> plot([0:.1:10],sin([0:.1:10]));
>
> hfig2 = figure('WindowStyle', 'docked')
> hax2 = axes;
> [x,y,z] = sphere(24);
> axes(hax2);surf(x,y,z,'FaceColor',[0 0.2 0.8])
> axis vis3d
>
> Clicking "Top/Bottom Tile" in the top right gives a similar
> layout.
>
> ~Adam

Thanks for the response. However, I don't know how to
implement something like that in my case. The above was
just an example of what happens when zooming
I am actually doing something similar with the plots but in
a GUI created in GUIDE. And I don't think you can really
dock a figure into a window in a GUI. It would be nice
though to restrict the viewable area of the axis to a
specific location. Sort of like put the plot axes in a
frame so it could not move or spill over covering out
uicontrols.
The only thing I can think off is to build the GUI using
multiple figs(which I don't really want to do).
I have also attempted to restrict the data created (like you
mentioned) but still can't quite get the view I want without
using either zoom or camera commands which change the size
of the plot axis displayed on the fig.

Thanks for the input.

Subject: Zoom / Camera Control in subplot

From: Adam

Date: 19 Sep, 2007 19:39:24

Message: 5 of 9

"Ben " <basburywvu.nospam@hotmial.com> wrote in message
<fcrscc$jtr$1@fred.mathworks.com>...
> "Adam " <not.my.email@mathworks.com> wrote in message >
> > Interesting. If your data is of the form z = f(x, y) you
> > may have to manually clip your data.
> >
> > Two dockable figures may be sufficient?
> >
> > hfig = figure('WindowStyle', 'docked');
> > plot([0:.1:10],sin([0:.1:10]));
> >
> > hfig2 = figure('WindowStyle', 'docked')
> > hax2 = axes;
> > [x,y,z] = sphere(24);
> > axes(hax2);surf(x,y,z,'FaceColor',[0 0.2 0.8])
> > axis vis3d
> >
> > Clicking "Top/Bottom Tile" in the top right gives a similar
> > layout.
> >
> > ~Adam
>
> Thanks for the response. However, I don't know how to
> implement something like that in my case. The above was
> just an example of what happens when zooming
> I am actually doing something similar with the plots but in
> a GUI created in GUIDE. And I don't think you can really
> dock a figure into a window in a GUI. It would be nice
> though to restrict the viewable area of the axis to a
> specific location. Sort of like put the plot axes in a
> frame so it could not move or spill over covering out
> uicontrols.
> The only thing I can think off is to build the GUI using
> multiple figs(which I don't really want to do).
> I have also attempted to restrict the data created (like you
> mentioned) but still can't quite get the view I want without
> using either zoom or camera commands which change the size
> of the plot axis displayed on the fig.
>
> Thanks for the input.

yeah, weird situation. What I would do, make a new figure
window for the 3d graph. You can add this to the opening
function

    hFig = figure;
    set(hFig, 'MenuBar', 'none', 'Toolbar', 'figure')

 % create callback to prevent figure from being
 % explicitly closed
    set(hFig, 'CloseRequestFcn', ...
   'guiServoLoop(''fig_CloseFcn'',gcbo,[],guidata(gcbo))');

    handles.figGraph = hFig; % add figure to handle list
    guidata(hObject, handles) % saves update to handles

then add the function

% --- Executes upon close request to graph window
function fig_CloseFcn(hObject, eventdata, handles)
    %do nothing

and add to your main figure's deletefcn or closerequestfcn
(not sure if it matters, I'm using the deleteFcn) the
following line
    delete(handles.figGraph)

otherwise I have no idea, gl.

~Adam

Subject: Zoom / Camera Control in subplot

From: Ben

Date: 20 Sep, 2007 00:48:29

Message: 6 of 9

"Adam " <not.my.email@mathworks.com> wrote in message
>
> yeah, weird situation. What I would do, make a new figure
> window for the 3d graph. You can add this to the opening
> function
>
> hFig = figure;
> set(hFig, 'MenuBar', 'none', 'Toolbar', 'figure')
>
> % create callback to prevent figure from being
> % explicitly closed
> set(hFig, 'CloseRequestFcn', ...
> 'guiServoLoop(''fig_CloseFcn'',gcbo,[],guidata(gcbo))');
>
> handles.figGraph = hFig; % add figure to handle list
> guidata(hObject, handles) % saves update to handles
>
> then add the function
>
> % --- Executes upon close request to graph window
> function fig_CloseFcn(hObject, eventdata, handles)
> %do nothing
>
> and add to your main figure's deletefcn or closerequestfcn
> (not sure if it matters, I'm using the deleteFcn) the
> following line
> delete(handles.figGraph)
>
> otherwise I have no idea, gl.
>
> ~Adam


Yeah, I don't think I have any other option but to create a
separate figure for the 3-d graph that I need to
zoom/explore since the plot axes keeps growing inside the
main GUI window.
Thank you for the tips. That should help me control the
extra figure a little better so the end user doesn't close
it by mistake,

Thanks Again.

Subject: Zoom / Camera Control in subplot

From: Sonsoles Romero García

Date: 21 Sep, 2007 07:15:27

Message: 7 of 9

I have the same problem, but creating a new window is NOT an
option for me. I need to zoom/explore a 3-d graph inside a
panel of a GUI.
A similar problem happens if the graphic is an histogram or
a bar graphic (only when the parent of the axes is a panel
the graphic grows all over the panel, it is interesting that
this doesn't happen if the parent is a figure).

For example, using Ben's example:
Zoom this is ok
hfig = figure('Position',[200 200 800 600]);
hax1 = axes('Position',[0.1 0.6 0.8 0.3]);
plot([0:.1:10],sin([0:.1:10]));
hax2 = axes('Position',[0.3 0.1 0.4 0.4]);
x = 1:1:100; y = 100*rand(1,1000);
axes(hax2);
hist(y,x,'FaceColor',[0 0.2 0.8]);

But, zoom this and you'll see what happens.
hfig = figure('Position',[200 200 800 600]);
panel = uipanel('position',[0.05 0.05 0.9 0.9]);
hax1 = axes('Position',[0.1 0.6 0.8 0.3],'parent',panel);
plot([0:.1:10],sin([0:.1:10]));
hax2 = axes('Position',[0.3 0.1 0.4 0.4],'parent',panel);
x = 1:1:100; y = 100*rand(1,1000);
axes(hax2);
hist(y,x,'FaceColor',[0 0.2 0.8]);

I am using Matlab 7.1.0.246 (R14) Service Pack 3

Subject: Zoom / Camera Control in subplot

From: Maarten Lont

Date: 22 Oct, 2007 10:08:30

Message: 8 of 9

"Sonsoles Romero García" <krokketilla@gmail.com> wrote in
message <fcvr2f$p15$1@fred.mathworks.com>...
> I have the same problem, but creating a new window is NOT an
> option for me. I need to zoom/explore a 3-d graph inside a
> panel of a GUI.
> A similar problem happens if the graphic is an histogram or
> a bar graphic (only when the parent of the axes is a panel
> the graphic grows all over the panel, it is interesting that
> this doesn't happen if the parent is a figure).
>
> For example, using Ben's example:
> Zoom this is ok
> hfig = figure('Position',[200 200 800 600]);
> hax1 = axes('Position',[0.1 0.6 0.8 0.3]);
> plot([0:.1:10],sin([0:.1:10]));
> hax2 = axes('Position',[0.3 0.1 0.4 0.4]);
> x = 1:1:100; y = 100*rand(1,1000);
> axes(hax2);
> hist(y,x,'FaceColor',[0 0.2 0.8]);
>
> But, zoom this and you'll see what happens.
> hfig = figure('Position',[200 200 800 600]);
> panel = uipanel('position',[0.05 0.05 0.9 0.9]);
> hax1 = axes('Position',[0.1 0.6 0.8 0.3],'parent',panel);
> plot([0:.1:10],sin([0:.1:10]));
> hax2 = axes('Position',[0.3 0.1 0.4 0.4],'parent',panel);
> x = 1:1:100; y = 100*rand(1,1000);
> axes(hax2);
> hist(y,x,'FaceColor',[0 0.2 0.8]);
>
> I am using Matlab 7.1.0.246 (R14) Service Pack 3

I found a workaround on a website. Add the line:

zoom on;

after you plot the data. Now you can zoom on every plot.

Best regards,
Maarten

Subject: Zoom / Camera Control in subplot

From: Sonsoles Romero Garc&#xED;a

Date: 4 Dec, 2007 19:58:53

Message: 9 of 9

"Maarten Lont" <m.lont@student.tue.nl> wrote in message
<ffhsqu$h66$1@fred.mathworks.com>...
> "Sonsoles Romero García" <krokketilla@gmail.com> wrote in
> message <fcvr2f$p15$1@fred.mathworks.com>...
> > I have the same problem, but creating a new window is NOT an
> > option for me. I need to zoom/explore a 3-d graph inside a
> > panel of a GUI.
> > A similar problem happens if the graphic is an histogram or
> > a bar graphic (only when the parent of the axes is a panel
> > the graphic grows all over the panel, it is interesting that
> > this doesn't happen if the parent is a figure).
> >
> > For example, using Ben's example:
> > Zoom this is ok
> > hfig = figure('Position',[200 200 800 600]);
> > hax1 = axes('Position',[0.1 0.6 0.8 0.3]);
> > plot([0:.1:10],sin([0:.1:10]));
> > hax2 = axes('Position',[0.3 0.1 0.4 0.4]);
> > x = 1:1:100; y = 100*rand(1,1000);
> > axes(hax2);
> > hist(y,x,'FaceColor',[0 0.2 0.8]);
> >
> > But, zoom this and you'll see what happens.
> > hfig = figure('Position',[200 200 800 600]);
> > panel = uipanel('position',[0.05 0.05 0.9 0.9]);
> > hax1 = axes('Position',[0.1 0.6 0.8 0.3],'parent',panel);
> > plot([0:.1:10],sin([0:.1:10]));
> > hax2 = axes('Position',[0.3 0.1 0.4 0.4],'parent',panel);
> > x = 1:1:100; y = 100*rand(1,1000);
> > axes(hax2);
> > hist(y,x,'FaceColor',[0 0.2 0.8]);
> >
> > I am using Matlab 7.1.0.246 (R14) Service Pack 3
>
> I found a workaround on a website. Add the line:
>
> zoom on;
>
> after you plot the data. Now you can zoom on every plot.
>
> Best regards,
> Maarten


The problem is when you zoom on the histogram because it
becomes bigger than the axes area (taking up all the panel)
and the same happens when I try to zoom a 3D graphic. I
don't know how to control the zoom for a 3D plot inside its
axes.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
3d zoom problem Sonsoles Romero García 21 Sep, 2007 03:20:21
subplots Ben 17 Sep, 2007 18:05:04
camera Ben 17 Sep, 2007 18:05:04
zoom Ben 17 Sep, 2007 18:05:04
rssFeed for this Thread

Contact us at files@mathworks.com