Filter löschen
Filter löschen

How can I change the colour of the axes?

8 Ansichten (letzte 30 Tage)
Andrew
Andrew am 7 Mär. 2024
Kommentiert: Voss am 8 Mär. 2024
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.

Akzeptierte Antwort

Voss
Voss am 7 Mär. 2024
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 Kommentare
Andrew
Andrew am 8 Mär. 2024
This works, thank you!
Voss
Voss am 8 Mär. 2024
You're welcome!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 7 Mär. 2024
ax.GridColor = 'k';
ax.GridAlpha = 1;
  1 Kommentar
Voss
Voss am 7 Mär. 2024
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;

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Stability Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by