setting axes to a specific colour

조회 수: 4 (최근 30일)
A Poyser
A Poyser 2024년 1월 8일
댓글: Dyuman Joshi 2024년 1월 9일
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
A Poyser
A Poyser 2024년 1월 9일
@Dyuman Joshi I figured it out. Thanks
Dyuman Joshi
Dyuman Joshi 2024년 1월 9일
Great. You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by