MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by moonman
on 6 Dec 2011

I am having 12 subplots in my figure All are required to have same labels How can i give them label by mentioning only one time?

*No products are associated with this question.*

Answer by Abhishek Gupta
on 6 Dec 2011

Accepted answer

One may use FINDOBJ to locate all subplots/axes on a figure and then use a FOR loop to label/title all the subplots. For example:

f=figure; subplot(2,2,1:2) text(.5,.5,'subplot(2,2,1:2)',... 'FontSize',14,'HorizontalAlignment','center') subplot(2,2,3) text(.5,.5,'subplot(2,2,3)',... 'FontSize',14,'HorizontalAlignment','center') subplot(2,2,4) text(.5,.5,'subplot(2,2,4)',... 'FontSize',14,'HorizontalAlignment','center')

ax = findobj(f,'Type','Axes'); for i=1:length(ax) ylabel(ax(i),{'Nice'}) title(ax(i),{'Very Nice'}) end

Hope this helps.

Abhi...

Answer by Jan Simon
on 6 Dec 2011

FigH = figure; subplot(1,2,1); subplot(1,2,2); AxesH = findobj(FigH, 'Type', 'Axes'); YLabelHC = get(AxesH, 'YLabel'); YLabelH = [YLabelHC{:}]; set(YLabelH, 'String', 'Y-label') TitleHC = get(AxesH, 'Title'); TitleH = [TitleHC{:}]; set(TitleH, 'String', 'The title');

## 0 Comments