setting axes to a specific colour

3 次查看(过去 30 天)
I am trying to make a graph where all of the axes are black
however the right y axes keeps being an uncontrolled colour
%
%
clear
close all
%
%
%%
%
%%
% extract data
TGA_1 = [29.044 29.07498 29.10418 29.13242 29.14578 29.17879 29.22682 29.23897 29.29634 29.31156;
100 99.99852 100.00471 100.00925 100.01266 100.0152 100.01706 100.01834 100.01913 100.01949];
TGA_2 = [29.043 29.0657 29.11248 29.11802 29.16212 29.17449 29.20546 29.22756 29.28798 29.31485;
100 100.00151 100.00219 100.0026 100.00287 100.00305 100.00316 100.00321 100.00319 100.00311];
% TGA_3 = OXOXCMC_03(:,[1,3]);
% TGA_4 = OXOXCMC_04(:,[1,3]);
%%
% mean of TGA analysis
% TGAsum = mean(all(:,2));
%%
% plot
figure1 = figure;
% set(axes,'YColor',[0 0 0]);
%
hold
Current plot held
plot(TGA_1(:,2));
plot(TGA_2(:,2));
% plot(TGA_3(:,2));
% plot(TGA_4(:,2));
% plot(TGA_1(:,1))
yyaxis('left');
ylabel('Thermogravimetric mass \%','Color',[ 0 0 0 ],'Interpreter','latex')
ax.YAxis(1).Color = [0 0 0];
yyaxis('right');
ylabel('Temperature $^{\circ}$C','Color',[ 0 0 0 ],'Interpreter','latex')
ax.YAxis(2).Color = [0 0 0];
plot(TGA_1(:,1),'--b')
How do I make sure the numbering on the right axis is black aswell?
Thanks in advance

采纳的回答

Dyuman Joshi
Dyuman Joshi 2024-1-8
移动:Dyuman Joshi 2024-1-8
You have to call gca first and assign it to the variable ax, and then modify the properties.
Otherwise ax will be defined as a struct -
% extract data
TGA_1 = [29.044 29.07498 29.10418 29.13242 29.14578 29.17879 29.22682 29.23897 29.29634 29.31156;
100 99.99852 100.00471 100.00925 100.01266 100.0152 100.01706 100.01834 100.01913 100.01949];
TGA_2 = [29.043 29.0657 29.11248 29.11802 29.16212 29.17449 29.20546 29.22756 29.28798 29.31485;
100 100.00151 100.00219 100.0026 100.00287 100.00305 100.00316 100.00321 100.00319 100.00311];
% TGA_3 = OXOXCMC_03(:,[1,3]);
% TGA_4 = OXOXCMC_04(:,[1,3]);
%%
% mean of TGA analysis
% TGAsum = mean(all(:,2));
%%
% plot
figure1 = figure;
% set(axes,'YColor',[0 0 0]);
%
hold on
plot(TGA_1(:,2));
plot(TGA_2(:,2));
% plot(TGA_3(:,2));
% plot(TGA_4(:,2));
% plot(TGA_1(:,1))
yyaxis('left');
ylabel('Thermogravimetric mass \%','Color',[ 0 0 0 ],'Interpreter','latex')
%Get current axes
ax = gca;
ax.YAxis(1).Color = [0 0 0];
yyaxis('right');
ylabel('Temperature $^{\circ}$C','Color',[0 0 0],'Interpreter','latex')
ax.YAxis(2).Color = [0 0 0];
plot(TGA_1(:,1),'--b')
  5 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by