Get selected point(s) on GUI subplot with brush

7 visualizaciones (últimos 30 días)
Lilian Darracq
Lilian Darracq el 15 de Jun. de 2017
Editada: Adam el 15 de Jun. de 2017
Hello fellow Matlab users,
I have been struggling for some time now on a problem, and i've looked for solutions everywhere but i can't seem to find one suiting my problem.
Basically, i have several interconnected GUI, the first ones running lots of simulations, analyzing the results, and send it to the next GUI. In this one, i retrieve the analyzing results, as a struct (which size depends on the simulations) containing differents arrays of results :
struct with fields:
interceptTime: [4.8000 4.8000 4.8000 5.0000 5.5000]
distMax: [9.1342 9.1342 9.1342 11.9404 8.2485]
timeMax: [0 0 0 0 0]
timeRatio: [1.0000 0.8571 0.4615 1.0000 1.0000]
The next time i do is subploting these results in the opening function of the next GUI, with the abcisse being the number of the according simulation, and i save the handles to the axes and the plots.
for i = 1:numRows
for j = 1:2
handles.axes{2*(i-1)+j} = subplot(numRows,2,2*(i-1)+j);
handles.plot{2*(i-1)+j} = plot(handles.xdata, getfield(analysisData, fname{i}));
end
end
And finally, i create a push button 'Select a simulation' :
handles.simulation_button = uicontrol('Parent',handles.figure1,...
'Style','pushbutton',...
'String','Select a simulation', ...
'Tag', 'simulation_button', ...
'Callback', {@simulation_button_callback, hObject});
Now, what i would want to do when i press this button, is to be able to click on of the graphs, and then to extract the number of the corresponding simulation, to be able to do some precise analysis later. I have found the tool 'brush', which could allow me to do exactly what i want, but i can't manage to get the selected data.
function simulation_button_callback(src, event, hObject)
handles = guidata(hObject);
guidata(hObject, handles);
mode = get(src, 'String');
if(strcmp(mode, 'Select a simulation'))
set(src, 'String', 'Done');
handles.brushobj = brush(handles.figure1);
set(handles.brushobj, 'Enable', 'on', 'ActionPostCallback', @brushCallback);
else
set(handles.brushobj, 'Enable', 'off');
set(src, 'String', 'Select a simulation');
end
guidata(hObject, handles);
I have tried to look into brushobj to find the data, to use the brush 'ActionPostCallback' property, and to look for the hidden brushHandles property of my handles.plot (as explained here http://undocumentedmatlab.com/blog/accessing-plot-brushed-data#comment-345181) but none of this methods worked for me.
Does anyone one have an idea how to do this ? Maybe brush is not the right tool for that ?
Cheers, Lilian
  1 comentario
Adam
Adam el 15 de Jun. de 2017
Editada: Adam el 15 de Jun. de 2017
What do you mean by 'none of this methods worked for me'? It's not a very helpful comment! What aspect of it didn't work? When I try using the link you post on a line object or a scatter object it works fine for me. I'm only using a single axes in a standalone figure, but that shouldn't make a difference - it is the line object from which the data is being pulled.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by