MATLAB Answers

0

Is it possible to add Plot Edit Toolbar functionality to a GUI?

Asked by Matthew Schroeder on 11 Jul 2011
Latest activity Commented on by mechie bud on 19 Jun 2019
I am creating a data visualization GUI, and I'd like to add the ability for the users to annotate the plots as they wish. The 'Plot Edit Toolbar' menu option would be perfect.
Any help would be appreciated!

  0 Comments

Sign in to comment.

2 Answers

Answer by Patrick Kalita on 12 Jul 2011
 Accepted Answer

Well, this is a little sneaky, but you can try this if you absolutely need to have this functionality. First, you can find the menu item with the "Plot Edit Toolbar" label and look at it's Callback property:
f = figure;
M = findall(f, 'Label', '&Plot Edit Toolbar');
get(M, 'Callback')
Now that you know what it's doing, you can call the same function that its using in your GUI.
I think we're getting into somewhat "undocumented" functionality here, so the standard warning about that (functionality could change in a future release without warning, etc.) applies here.

  5 Comments

@Matthew, you might want to post a new question about that.
@Fangjun, the name of the function is 'viewmenufcn'. It is being given a string input argument 'PloteditToolbar'. It is equivalent to viewmenufcn('PloteditToolbar')
The profiler can help to find the applied callback. Start the profile, hit the menu function, inspect the profiler report for the used functions.
=> plotedit(FigH, 'plotedittoolbar', 'toggle')
Thanks, Patrick. The reason I am asking is to see if there is an hidden API to use the interactive Brush functionality. Do you see a possibility? See this post. http://www.mathworks.com/matlabcentral/answers/11439-selecting-data-from-a-plot-in-a-gui

Sign in to comment.


Answer by Jan
on 11 Jul 2011

The toolbar of a figure is disabled, if an UICONTROL is created. But you can enable it manually:
figure('Toolbar', 'figure');
uicontrol('Style', 'Pushbutton');
Or if you use GUIDE to create the figure, you can enable the toolbar in the CreateFcn also.

  5 Comments

I use GUIDE to create the figure, as well as specifying which toolbar options I want to add (pan, zoom, data cursor, etc). I tried adding
set(handles.figure1,'toolbar','figure');
to the opening function, but it doesn't add the toolbar I want. I want it to add the toolbar that you get when you go to
View > Plot Edit Toolbar
from a figure that is not in a GUI (annotation tools). I don't necessarily want the users to have complete ability to edit the plots, just to be able to anotate them.
Thank you in advance!
I am trying to do something very similar let me know if you come up with a solution!
Please post the solution

Sign in to comment.