How do I create a function (located in a separate file) that puts an interactive axes in a GUI tab (with the GUI defined in a script)?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Minh Tran
el 6 de Sept. de 2015
Comentada: Minh Tran
el 7 de Sept. de 2015
I created a ML GUI script similar to the following:
fig1 = figure; % Window for GUI
tbgp = uitabgroup(fig1); % Create a tab group for that window
t1 = uitab(tbgp, 'Title', 'tab1'); % Create first tab under 'tbgp'
t2 = uitab(tbgp, 'Title', 'tab2'); %Create 2nd tab under 'tbgp'
Now, I want to add 2 "interactive" axes/plots, each with different properties, in both of the tabs defined above. I can write code in the script, but I'd like to do this using a function defined in a separate file located on the same ML path(so that I can just call the function whenever I want a similar interactive plot on something. In this case, I want the plots on two different tabs).
<IN A SEPARATE FILE>
function showInteractivePlot( desiredTab )
axes(desiredTab); % Draw axes on the desired tab
pan(fig1); % I want to enable panning on the axes located on the 'desiredTab', which
% is itself located in fig1
end
In the end, I would like to do the following in my GUI script:
fig1 = figure; % Window for GUI
tbgp = uitabgroup(fig1); % Create a tab group for that window
t1 = uitab(tbgp, 'Title', 'tab1'); % Create first tab under 'tbgp'
t2 = uitab(tbgp, 'Title', 'tab2'); %Create 2nd tab under 'tbgp'
% Add interactive plot to t1
showInteractivePlot(t1);
% Add interactive plot to t2
showInteractivePlot(t2);
0 comentarios
Respuesta aceptada
Walter Roberson
el 6 de Sept. de 2015
A uitab is not an axes, but an axes may be contained within a uitab.
Assuming that you want to create the axes within the tab, then
function showInteractivePlot( desiredTab )
ax = axes('Parent', desiredTab); % Create axes on the desired tab
h = pan(ancestor(desiredTab,'figure')); %panning needs to be turned on for the figure
setAllowAxesPan(h, ax, true); %enable panning for this axes
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Axes Appearance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!