Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: OVERVIEW PLOT ZOOM DRAG PAN

Subject: OVERVIEW PLOT ZOOM DRAG PAN

From: Frank Pezzulo

Date: 15 May, 2008 17:53:02

Message: 1 of 2

Dear All,

I have a problem. I have a GUI where there are two axes, one
large and one smaller. I would that when i plot something in
large axes, in the small axes there are the same plots but
more small. Other when i pan in large axes i would that in
small axes there is a rectangular that see what part of
large axes i'm panning .... so i would like google map where
there are a large map and a little overview.

I know that in Matlab File Exchange there is a function
called "OVERVIEW PLOT" that it do it, but i don't know how
modify it for my GUI system .... CAN YOU HELP ME?

THANKS

FRANCESCO

Subject: Re: OVERVIEW PLOT ZOOM DRAG PAN

From: helper

Date: 15 May, 2008 18:16:01

Message: 2 of 2

"Frank Pezzulo" <john.doe.nospam@mathworks.com> wrote in
message <g0ht9u$83h$1@fred.mathworks.com>...
> Dear All,
>
> I have a problem. I have a GUI where there are two axes,
one
> large and one smaller. I would that when i plot something
in
> large axes, in the small axes there are the same plots but
> more small.


When you plot to the big axis, use the handle:

plot(hBigAxis, xData, yData)

And just repeat the same command for the small axis:

plot(hLittleAxis, xData, yData)


In addition, do two more things. Be sure to "hold" the
little axis, and plot a line at some arbitrary point to be
used as your rectangle later:

hold(hLittleAxis,'on')
hRectangle = plot(0,0);


> Other when i pan in large axes i would that in
> small axes there is a rectangular that see what part of
> large axes i'm panning .... so i would like google map
where
> there are a large map and a little overview.

You can specify callbacks for panning and zooming
operations. For example, when you create the figure, use
an output variable to get the figure's handle:

hFig = figure;

Then, use the following commands to set the panning and
zooming callbacks:

hZoom = zoom(hFig);
hPan = pan(hFig);

set(hZoom,'ActionPostCallback',@(x,y)PanZoom_Callback)
set(hPan,'ActionPreCallback',...
  @(x,y)set(hFig,'WindowButtonMotionFcn',...
  @(x,y)PanZoom_Callback))
set(hPan,'ActionPostCallback',...
  @(x,y)set(hFig,'WindowButtonMotionFcn',...
  []))


Now, you need to create a function
called "PanZoom_Callback.m". This callback will be called
once when you finish zooming or many times while you are
panning. Within this function, do something like:

function PanZoom_Callback
axLims = axis(hBigAxis);
xRect = axLims(1) + axLims(3)*[0 1 1 0 0];
yRect = axLims(2) + axLims(4)*[0 1 1 0 0];
set(hRectangle,'xdata',xRect,...
  'ydata',yRect)
drawnow



The biggest problem you will have that I have not explained
is how to make all these handles (i.e., hBigAxis, hFig,
hPan,...) available when you need them.

For more information on this, search for "passing variables
within GUIs" or "using nested functions in GUIs". There
are a lot of references in the MATLAB documentation and in
this newsgroup on this topic.

I hope this gets you started.

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
overview plot zoom drag pan Frank Pezzulo 15 May, 2008 13:55:08
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics