Black axes for yyaxis (not default blue and orange)
1.204 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Heidi Hirsh
am 23 Mär. 2019
Kommentiert: DGM
am 10 Sep. 2023
I'm having a hard time making the two y axes in my yyaxis plot black instead of the default blue left axis and orange left axis. I think I need to call the axis handle for each but I'm not sure how to define them for multiple y axes.
figure
yyaxis left
plot(btimestamp(k1:k2),Bmean3637(k1:k2),'k');
ylabel('BEUTI')
ylim([-5 40])
yyaxis right
plot(btimestamp(k1:k2),t_mean(k1:k2),'g-');
hold on;
plot(btimestamp(k1:k2),b_mean(k1:k2),'b-');
ylabel('Mean Daily pH')
ylim([7.2 8.2])
legend('BEUTI','Upper pH','Lower pH')
datetick
set(AX,{'ycolor'},{'r';'b'})
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Mär. 2019
Try this:
figure
yyaxis left
plot((1:10), rand(1, 10), 'g')
yyaxis right
plot((5:15), sin((5:15)/5), 'r')
ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';
Experiment to get the result you want.
4 Kommentare
Sara Fawal
am 23 Jul. 2020
Hello Star,
Is there a way to set ALL the Y axis colors in a subplot to black using the findall command?
I want to do this: set(findall(gcf, 'ALL Y Axis Colors', 'k'))
Can it be done.
Thank you
Weitere Antworten (1)
Julian Dönges
am 20 Aug. 2021
colororder({'b','m'})
yyaxis left
y = [1 2; 3 4];
plot(y)
yyaxis right
z = [4 3; 2 1];
plot(z)
legend
To make both sides black, you would write the first line as
colororder({'k','k'})
4 Kommentare
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!