Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Clickable subplots
Date: Mon, 20 Aug 2007 16:47:57 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 89
Message-ID: <facgjt$6kf$1@fred.mathworks.com>
References: <faaglg$4k6$1@fred.mathworks.com> <facc2p$8ve$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187628477 6799 172.30.248.37 (20 Aug 2007 16:47:57 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 20 Aug 2007 16:47:57 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1030060
Xref: news.mathworks.com comp.soft-sys.matlab:424641



Hi,
Thanks for your very helpful reply. I appreciate it very
much! I'm running into a few issues implementing it, however.

The first issue was that setting the callback fcn, as in:
set(h, 'ButtonDownFcn', @mycallbackfcn)

is somehow undone by calling plot(...) in the next line of
code. I verified by stepping through the code. Before
calling set, ButtonDownFcn is empty as shown here:

K>> get(hOS, 'ButtonDownFcn')
ans =      ''

after calling set, it is set as shown here:

K>> get(hOS, 'ButtonDownFcn')

ans =     @GenerateFullSizePlotFromSubplot

then after calling plot, the ButtonDownFcn is unset
automatically:

K>> get(hOS, 'ButtonDownFcn')
ans =      ''

I fixed this by reversing the order of the lines - I plot to
the axes first, then set the ButtonDownFcn. However, the
fact that this happens concerns me. It tells me that I don't
really understand something.

Now I am hitting a few more issues that I have not solved.

When I call 
mydata = get(gca,'UserData');
I get []
However, using the property inspector, I can see that the
UserData exists and is correct. It is a string. And gca
returns a value of 534.0007, so I assume gca is returning a
valid subplot.

Any idea how I can get the UserData (or any other property)
from the callback function? What should I look for in debugging?

The other strange thing is that some of my subplots respond
to mouse clicks and some do not. I set ButtonDownFcn on all
of them the same - I do it in a loop. Some subplots seem to
lose the callback and some don't. That's really strange. Any
ideas what I should look for?

Finally, the following code isn't working for me:
if strcmp(get(hFig,'SelectionType'),'open')

Even on a double click the comparison fails.

For testing I am simply responding to a single click, but I
would like to know what the problem is.
Thanks.

"Titus" <titus.edelhofer@mathworks.de> wrote in message
<facc2p$8ve$1@fred.mathworks.com>...
> 
> "G.A.M. " <gam32225@yahoo.co> schrieb im Newsbeitrag 
> news:faaglg$4k6$1@fred.mathworks.com...
> > Hi, I have a figure with many small subplots (as many as 80
> > or more). I would like to add functionality that would allow
> > me to double click a subplot to display a full size plot
> > with more details. Any suggestions on how to do this in an
> > m-file?
> 
> Hi,
> use the ButtonDownFunction-property of the subplot:
> h = subplot(n,m,i);
> set(h, 'ButtonDownFcn', @mycallbackfcn)
> 
> and in mycallbackfcn.m:
> 
> function mycallbackfcn(hObject, eventdata)
> hFig = get(hObject, 'parent');
> if strcmp(get(hFig,'SelectionType'),'open')
>   % this was a double click, do something
>   disp('do something')
> end
> 
> Hope, this helps,
> Titus
> 
>