yyaxis関数使用時にy軸の色が変えられない

37 visualizaciones (últimos 30 días)
佳琳 杉浦
佳琳 杉浦 el 14 de Abr. de 2022
Respondida: Hernia Baby el 15 de Abr. de 2022
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; %軸目盛のフォントサイズ

Respuestas (1)

Hernia Baby
Hernia Baby el 15 de Abr. de 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
ax =
Axes with properties: YAxisLocation: 'right' YAxis: [2×1 NumericRuler] YLim: [-150 150] XLim: [0 10] XScale: 'linear' YScale: 'linear' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Show all properties
YAxisが怪しそうです
ax.YAxis(1).Color = 'k'
ax =
Axes with properties: YAxisLocation: 'right' YAxis: [2×1 NumericRuler] YLim: [-150 150] XLim: [0 10] XScale: 'linear' YScale: 'linear' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Show all properties
ax.YAxis(2).Color = 'r'
ax =
Axes with properties: YAxisLocation: 'right' YAxis: [2×1 NumericRuler] YLim: [-150 150] XLim: [0 10] XScale: 'linear' YScale: 'linear' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Show all properties

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!