How can I change the colour of the axes?

16 次查看(过去 30 天)
TL;DR - Can't change axes colour, but can manually change in axes properties (not ideal).
No matter what I try, the colour of the axes on the figure below cannot be changed. I do not want the default gray colour, as I am trying to export it in tikz format. I have used this to try change the axes:
ax = gca;
ax.XColor = 'k';
ax.YColor = 'k';
Here is the current code:
hfig = figure; % save the figure handle in a variable
num = [1];
den = [1 20 20];
sys = tf(num, den);
ts = 0.01;
sys_d = c2d(sys, ts, 'zoh');
step(10, sys, 'b-', sys_d, 'r--');
title('System Step Response - $T_{c}=10$')
legend()
grid("minor")
% fname = 'lab-1-prac-1-step-resp';
%
% picturewidth = 20; % set this parameter and keep it forever
% hw_ratio = 0.65; % feel free to play with this ratio
% set(findall(hfig,'-property','FontSize'),'FontSize',17) % adjust fontsize to your document
%
% set(findall(hfig,'-property','Box'),'Box','off') % optional
% set(findall(hfig,'-property','Interpreter'),'Interpreter','latex')
% set(findall(hfig,'-property','TickLabelInterpreter'),'TickLabelInterpreter','latex')
% set(hfig,'Units','centimeters','Position',[3 3 picturewidth hw_ratio*picturewidth])
% pos = get(hfig,'Position');
% set(hfig,'PaperPositionMode','Auto','PaperUnits','centimeters','PaperSize',[pos(3), pos(4)])
%
% print(hfig,fname,'-dpdf','-vector','-fillpage')
% %print(hfig,fname,'-dpng','-painters')
% matlab2tikz( 'lab-1-prac-1-step-resp.tikz', 'height', '\fheight', 'width', '\fwidth' );
Long story short, I am a newbie here and used Octave GNU for plots, however it does not produce LaTeX plots that nicely, in short it either crashes or produces blank pdf's.

采纳的回答

Voss
Voss 2024-3-7
hfig = figure; % save the figure handle in a variable
num = [1];
den = [1 20 20];
sys = tf(num, den);
ts = 0.01;
sys_d = c2d(sys, ts, 'zoh');
step(10, sys, 'b-', sys_d, 'r--');
title('System Step Response - $T_{c}=10$')
legend()
grid("minor")
ax = findall(hfig,'Type','axes');
set(ax,'XColor','k','YColor','k')

更多回答(1 个)

Walter Roberson
Walter Roberson 2024-3-7
ax.GridColor = 'k';
ax.GridAlpha = 1;
  1 个评论
Voss
Voss 2024-3-7
hfig = figure; % save the figure handle in a variable
num = [1];
den = [1 20 20];
sys = tf(num, den);
ts = 0.01;
sys_d = c2d(sys, ts, 'zoh');
step(10, sys, 'b-', sys_d, 'r--');
title('System Step Response - $T_{c}=10$')
legend()
grid("minor")
ax = gca();
ax.GridColor = 'k';
ax.GridAlpha = 1;

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Stability Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by