MATLAB Answers

0

sigma deletes the axis grid

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

  0 件のコメント

サインイン to comment.

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().

  0 件のコメント

サインイン to comment.



Translated by