How can I change the color and font on the second y axis of a subplot?
Ältere Kommentare anzeigen
I have a Matlab subplot:
subplot(4,2,2); plotyy(x,y,x,z)
xlabel('x','FontSize',8); set(gca,'FontSize',8); legend('y','z','Location','Best');
set(legend,'FontSize',8); title('y and z','FontSize',10);
But the font on the right axis is 10, not 8, and the color is blue. I would to change the color and font. Many thanks for any help!
Akzeptierte Antwort
Weitere Antworten (2)
Mischa Kim
am 19 Apr. 2014
Bearbeitet: Mischa Kim
am 19 Apr. 2014
0 Stimmen
SSB, one way would be to use the plot tools. See icon in the lower right corner in the screen shot:

In the plot tools editor you can select the figure objects and change their properties. Once you are done adapting your figure you can choose > File > Generate Code... and learn how to do all those changes programmatically.
3 Kommentare
SSB
am 19 Apr. 2014
Mischa Kim
am 19 Apr. 2014
In the plot browser start by selecting the corresponding Axes (no title) and continue by changing properties as needed.

SSB
am 19 Apr. 2014
DanielFromIllinois
am 1 Feb. 2023
0 Stimmen
You can also find the YAxis properties for left and right like so:
fh = figure;
x = 1:10;
y = 1:10;
%pltos on the left axis.
plot(x,y)
%plots on the right axis.
yyaxis right
plot(x,y*2)
%The YAxis object is stored under the Axes child of the figure.
%It has a property 'Color' that you can use to set the color to black.
%The line below will set the color to black.
fh.Children.YAxis(2) = 'k';
Kategorien
Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!