Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Datacursormode for GUI with two Axes

Subject: Datacursormode for GUI with two Axes

From: Nima Nikvand

Date: 30 Dec, 2012 06:12:21

Message: 1 of 2

Hello everyone,

I have a GUI with two axes, which are supposed to display two different plots, and I will be using datacursormode to get the information for the plots. I understand it is not possible to enable datacursormode for only one of the axes in my GUI, however, as suggested in previous questions, I was going to use ancestor function to figure out which one of the axes has been clicked on. Below is my general code:


    dcmObj=datacursormode(handles.figure1);

        set(dcmObj,'Enable','on',...
           'SnapToDataVertex','on', ...
           'DisplayStyle','datatip',...
           'UpdateFcn',@datatextbox);
       p = ancestor(dcmObj,'axes')

however p is returning an empty matrix (p=[]). I'd greatly appreciate your suggestions.

Subject: Datacursormode for GUI with two Axes

From: Matt J

Date: 30 Dec, 2012 07:56:14

Message: 2 of 2

"Nima Nikvand" <nnikvand@uwaterloo.ca> wrote in message <kbom05$jsm$1@newscl01ah.mathworks.com>...
>
> dcmObj=datacursormode(handles.figure1);
>
> set(dcmObj,'Enable','on',...
> 'SnapToDataVertex','on', ...
> 'DisplayStyle','datatip',...
> 'UpdateFcn',@datatextbox);
> p = ancestor(dcmObj,'axes')
>
> however p is returning an empty matrix (p=[]). I'd greatly appreciate your suggestions.

You can't get the axis from the dcmObj. The dcmObj is a child of the figure, not any of the axes.

Call GCA inside datatextbox and return its output using nested functions, as I described in your other post.

Tags for this Thread

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.

Contact us