yyaxis関数使用時にy軸の色が変えられない
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
yyaxis関数を用いて2軸グラフを作成したいのですが、y軸の色がどうしても変えられません。「.YColor」や「YAxis(1).Color」を使っても、2軸両方ともデフォルトの色(青と赤)のままでした。
解決方法を教えていただきたいです。
以下、コードです。
figure(11)
yyaxis left
plot(distance_h1,v_h1,'r','LineWidth',2)
ylabel('Velocity [m/s]','FontSize',30,'Interpreter','latex')
axis([0 1.5 0 0.5])
yyaxis right
plot(distance_h1,p_h1,'k','LineWidth',2)
ylabel('Pitch angle [$^\circ$]','FontSize',30,'Interpreter','latex')
axis([0 1.5 -3 3])
grid on
xlabel('Travelled distance [m]','FontSize',30,'Interpreter','latex') %各軸ラベルを斜体でかつ諸々設定する
legend('Velocity','Pitch angle', 'FontSize',10,'Interpreter','latex','Location','northwest')
axis_obj = gca; %軸の字体
axis_obj.YColor = 'k';
axis_obj.FontSize = 18; %軸目盛のフォントサイズ
0 Kommentare
Antworten (1)
Hernia Baby
am 15 Apr. 2022
axis_objがどのような値を持っているか確認してみてください
おそらく axis_ob j.YAxis(1).Color で対応可能かなと思っています
clc,clear,close all;
x = linspace(0,10);
y = sin(3*x);
yyaxis left
plot(x,y)
z = sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z)
ylim([-150 150])
ax = gca
YAxisが怪しそうです
ax.YAxis(1).Color = 'k'
ax.YAxis(2).Color = 'r'
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!