Azzera filtri
Azzera filtri

How can I change the colour of the axes?

8 visualizzazioni (ultimi 30 giorni)
Andrew
Andrew il 7 Mar 2024
Commentato: Voss il 8 Mar 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.

Risposta accettata

Voss
Voss il 7 Mar 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')

Più risposte (1)

Walter Roberson
Walter Roberson il 7 Mar 2024
ax.GridColor = 'k';
ax.GridAlpha = 1;
  1 Commento
Voss
Voss il 7 Mar 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;

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by