Note, Robert helpfully reminded me to switch my 'HandleVisibility' back to 'on' regarding some other issues I had been having with this MWE. That does not solve the rotate3d issue.
Programmatic UI Toolbar Issues/Questions: rotate3d does not refresh until un-clicked + others
2 views (last 30 days)
Show older comments
I am including my MWE below (requires GUI layout toolbox). I have a programmatic UI that will do a scatter3 plot in one section. I have included the figure toolbar so that I might be able to zoom and rotate the scatter plot. This lead to several questions, of which I have found only partial answers in the documentation/forums. I am asking them all here since the same MWE should function for all questions.
1) When I use the rotate3d tool from the menu bar, and then rotate my plot, the plot disappears and does not refresh. It will reappear once I have deselected the rotate3d uitoggle. Why? How can I avoid this? It really ruins the usefulness of rotating my scatter plot. Note that this still happens when accessing rotate3d programmatically: e.g. rotate3d(gui.ViewAxes), so building my own custom toolbar will not fix this.
Now, the plot also disappears when I hit the colorbar button, and reappears when deselected. Which leads to the next two questions:
(2) I want to eliminate a bunch of the buttons from the toolbar but keep zoom, pan, and rotate3d. This is simple in GUIDE, but I wish to do it programmatically. Is the only way really to either A) build an entire custom toolbar or B) go through the whole findall/delete procedure for every unwanted button?
(3) The toolbar really should be attached to the plot axes, not the full figure. I know I have read some Jan Simon responses that this is not possible, though there are some FEX workarounds. However, I may wind up with multiple axes on the same UI which I want to save as e.g. .png files independently. The save pushbutton currently saves the entire figure. I would nominally want a save button for each individual axes. I do not like the idea of opening a new figure for every single axes if the controls and both axes are closely related.
Please, no responses suggesting I go back to GUIDE.
Thanks!
MWE below.
function gui = guiTest
gui = struct();
% Initialize Window
scrsz = get(groot,'ScreenSize');
gui.Window = figure( ...
'Name', 'A Test Window', ...
'NumberTitle', 'off', ...
'MenuBar', 'none', ...
'Toolbar', 'Figure', ...
'HandleVisibility', 'off',...
'OuterPosition', [3*scrsz(4)/4 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2]);
% Create Main Layout
mainLayout = uiextras.HBoxFlex(...
'Parent',gui.Window,...
'Spacing',3);
% Left Side Control Panel
controlPanel = uiextras.BoxPanel(...
'Parent',mainLayout,...
'Title','Controls go here');
% Right Side Plotting
gui.ViewPanel = uiextras.BoxPanel(...
'Parent', mainLayout,...
'Title','Axes Panel Name');
% Relative sizes of main layout sections
set(mainLayout, 'Sizes', [-1 -2]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Right Side Plotting %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gui.ViewAxes = axes(...
'Parent',gui.ViewPanel);
X = rand(100,1); Y = rand(100,1); Z = rand(100,1);
scatter3(X,Y,Z,'Parent',gui.ViewAxes); axis(gui.ViewAxes, 'equal');
end
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!