How can I change the color and font on the second y axis of a subplot?
163 views (last 30 days)
Show older comments
Answered: DanielFromIllinois on 1 Feb 2023
I have a Matlab subplot:
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!
Azzi Abdelmalek on 19 Apr 2014
title('y and z','FontSize',10)
Sara Fawal on 23 Jul 2020
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.
More Answers (2)
Mischa Kim on 19 Apr 2014
Edited: Mischa Kim on 19 Apr 2014
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.
DanielFromIllinois on 1 Feb 2023
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.
%plots on the right axis.
%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';
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!