Clear Filters
Clear Filters

Create a subplot that can toggle linkaxes.

1 view (last 30 days)
Scott
Scott on 9 Apr 2013
I have a GUI that creates subplots of user selected data. I want the user to have the ability to toggle between having the x-axis of each subplot linked using linkaxes. Is there a way to embed this functionality in the created subplot figure?
Right now, the axes are either linked or they are not; I don't know how to toggle between the two without returning to and using a pushbutton on the main GUI.
Thank you in advance, Scott
  2 Comments
Jan
Jan on 9 Apr 2013
What is the actual question? You do not want to create a push-button? Why not? Would a corresponding menu in the figure's or subplot's context menu solve the problem? Or what about an entry in the menu bar?
Scott
Scott on 9 Apr 2013
Those are all good suggestions. I would prefer to have a pushbutton on the created subplot figure. I just don't know how to do that. I only know how to add pushbuttons using guide. If there's a way to do it programmatically, so I could create a figure, add subplots, and add a pushbutton, I think that would solve my problem.

Sign in to comment.

Answers (1)

Jan
Jan on 9 Apr 2013
Edited: Jan on 9 Apr 2013
Open a figure and create a button:
FigH = figure;
ButtonH = uicontrol(FigH, 'Style', 'pushbutton', ...
'Units', 'pixels', ...
'Position', [10, 10, 120, 22], ...
'String', 'Link axes', ...
'Callback', @yourCallbackFcn);
  1 Comment
Scott
Scott on 9 Apr 2013
Thank you! However, when I use this solution, I lose other plotting tools. Is there a way to keep them (pan, zoom, data cursor, etc) on the figure as well?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!