How to change thickness and font of all axes in a subplot?

34 次查看(过去 30 天)
I'm plotting a step response of a single input , multi output system using step command. The result is a n*1 subplot. How do I change the font or line thickness of all the subplots together. When I use the following command:
set(gca,'FontName','Arial','FontSize',12,'FontWeight','Bold',  'LineWidth', 2);
it only change the last subplot.

采纳的回答

MathWorks Support Team
The reason for the behavior that only the last axes is modified is because in your command, you are using 'gca' to set the properties. Using 'gca' gets hold of only the current axes, which in this case would be the last axes that was plotted on the figure.
In order to workaround the issue, you would need to get all the axes handles in the figure. To achieve this, you may use'findobj' function as findobj(gcf,'type','axes'). Please refer to the following code snippet:
subplot(211); plot(1:10);
subplot(212); plot(randi(10,1,10));
set(findobj(gcf,'type','axes'),'FontName','Arial','FontSize',12,'FontWeight','Bold', 'LineWidth', 2);

更多回答(0 个)

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by