Potential Bug with App Designed to Create Subplots of Polar Axes?

2 Ansichten (letzte 30 Tage)
Michael
Michael am 5 Jun. 2019
I am trying to programmatically generate a set of polar subplots in my Matlab application. It seems to work almost perfectly, but when I generate polar axis subplots in my app, an empty figure window is generated at the first subplot call (and none of the others). I thought I had left a 'figure' command in my code somewhere, but that is not the problem. I have included a minimally functional reproduction of the problem in the pasted code below (this site won't allow me to attach a file with the .mlapp extension). I tried adding a breakpoint at the first 'ax1 = subplot(2...' call and then stepping into the subplot function, but the figure window pops up as soon as the debugger jumps into that function. I am at a loss and want to know if I have messed something up, or if this is a bug that needs fixing.
The example application below contains one button, whose callback function generates the subplots.
Please let me know if you need more details to answer this question.
-Michael
classdef subplottestapp < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Panelwithsubplotsofpolaraxes matlab.ui.container.Panel
CallpolarsubplotfunctionButton matlab.ui.control.Button
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CallpolarsubplotfunctionButton
function CallpolarsubplotfunctionButtonPushed(app, event)
%%%%%%%%%%%%%%%%%%THIS IS THE CODE THAT NEEDS ASSESSMENT
%Required to turn off auto resize for subplots.
%See: https://www.mathworks.com/help/matlab/creating_guis/graphics-support-in-app-designer.html
app.Panelwithsubplotsofpolaraxes.AutoResizeChildren = 'off';
%Plot in the panel
plotparent = app.Panelwithsubplotsofpolaraxes;
%Create two subplots, each with polar axes
%Adapted from: https://www.mathworks.com/help/matlab/creating_guis/graphics-support-in-app-designer.html
ax1 = subplot(2,1,1,polaraxes,'Parent',plotparent);
polarplot(ax1,360*rand(5,1)*pi/180,rand(5,1));
ax2 = subplot(2,1,2,polaraxes,'Parent',plotparent);
polarplot(ax2,360*rand(5,1)*pi/180,rand(5,1));
%%%%%%%%%%%%%%%%%%THIS IS THE CODE THAT NEEDS ASSESSMENT
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 360 464];
app.UIFigure.Name = 'UI Figure';
% Create Panelwithsubplotsofpolaraxes
app.Panelwithsubplotsofpolaraxes = uipanel(app.UIFigure);
app.Panelwithsubplotsofpolaraxes.Title = 'Panel with subplots of polar axes';
app.Panelwithsubplotsofpolaraxes.Position = [1 1 360 464];
% Create CallpolarsubplotfunctionButton
app.CallpolarsubplotfunctionButton = uibutton(app.Panelwithsubplotsofpolaraxes, 'push');
app.CallpolarsubplotfunctionButton.ButtonPushedFcn = createCallbackFcn(app, @CallpolarsubplotfunctionButtonPushed, true);
app.CallpolarsubplotfunctionButton.Position = [186 413 157 22];
app.CallpolarsubplotfunctionButton.Text = 'Call polar subplot function';
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = subplottestapp
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end

Antworten (0)

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by