sigma deletes the axis grid

2 次查看(过去 30 天)
Giuseppe Naselli
Giuseppe Naselli 2019-7-17
编辑: Adam Danz 2019-7-19
Hi All,
my code is below
myFigure=figure; % create a figure
ax1 = subplot(231, 'Parent', myFigure,'UserData','my_stuff','nextplot', 'add','XGrid','on','YGrid','on'); % create axix and set grid on in x and y
sigma(ax1,mySystem); % plot
The 2nd line create an axis with grid on, but then with the 3rd line the grid disappears
I can reset the grid back on with a 4th line as
grid(ax1,'on')
however, I was wondering why "sigma" ignore my initial statement in subplot ('XGrid','on','YGrid','on')
Is there a setting in sigma/subplot that I can use?
Thanks
G

回答(1 个)

Adam Danz
Adam Danz 2019-7-17
编辑:Adam Danz 2019-7-19
Short answer: You need to add the grid after calling sigma().
Long answer:
Assuming you're using the DynamicSystem method (toolbox \ control \ ctrlanalysis \ @DynamicSystem \ sigma.m), sigma() calls the helper function sigmaplot() which calls ltiplot() which does the plotting.
If "hold on" was not called prior to calling sigma(), the axes are cleared using cla() in ltiplot() as shown below.
% Clear and reset axes if new plot
if NewPlot
% Notify the live editor of newplot
matlab.graphics.internal.clearNotify(ax);
% Clear any existing response plot upfront (otherwise style
% settings below get erased by CLA in respplot/check_hold)
if ~isempty(h)
cla(h.AxesGrid,handle(ax)) % speed optimization
else
cla(ax,'reset')
end
If "hold on" was called prior to calling sigma(), ltiplot() changes a bunch of axes properties. Listed below are the default PlotOptions created in ltiplot() and the changes made to the axis properties.
PlotOptions =
FreqUnits: 'auto'
FreqScale: 'log'
MagUnits: 'dB'
MagScale: 'linear'
IOGrouping: 'none'
InputLabels: [1×1 struct]
OutputLabels: [1×1 struct]
InputVisible: {'on'}
OutputVisible: {'on'}
Title: [1×1 struct]
XLabel: [1×1 struct]
YLabel: [1×1 struct]
TickLabel: [1×1 struct]
Grid: 'off' % <-----
GridColor: [0.15 0.15 0.15]
XLim: {[1 10]}
YLim: {[1 10]}
XLimMode: {'auto'}
YLimMode: {'auto'}
set(ax,...
'XGrid', PlotOptions.Grid,... % <-----
'YGrid', PlotOptions.Grid,... % <-----
'XColor', PlotOptions.TickLabel.Color,...
'YColor', PlotOptions.TickLabel.Color,...
'FontSize', PlotOptions.TickLabel.FontSize,...
'FontWeight', PlotOptions.TickLabel.FontWeight,...
'FontAngle', PlotOptions.TickLabel.FontAngle,...
'Selected', 'off')
So, whether you hold your axes or not, the grids will be cleared. As you've discovered, you can add them back in after calling sigma().

类别

Help CenterFile Exchange 中查找有关 Response Computation and Visualization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by