フィルターのクリア

How can I change the colour of the axes?

8 ビュー (過去 30 日間)
Andrew
Andrew 2024 年 3 月 7 日
コメント済み: Voss 2024 年 3 月 8 日
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')
  2 件のコメント
Andrew
Andrew 2024 年 3 月 8 日
This works, thank you!
Voss
Voss 2024 年 3 月 8 日
You're welcome!

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeStability Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by