One common Y-axis label for two or more plots

5 views (last 30 days)
Hello,
How can I get just one Y-Axis Label to span two or more plots? That is, center the Y-axis label between the plots in the rows?
Here is my code:
FigH = figure;
subplot(2,1,1); subplot(2,1,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');

Accepted Answer

Madhu Govindarajan
Madhu Govindarajan on 13 Nov 2015
I would propose you to get the Handle of the subplots and then work with that.
Sample code
FigH = figure;
SP1H = subplot(2,1,1);
SP2H = subplot(2,1,2);
YLabel1H = get(SP1H,'YLabel');
set(YLabel1H,'String','YLabelThatIWant');
set(YLabel1H,'Position',[-0.0542 0 0]);
Title1H = get(SP1H,'Title');
set(Title1H,'String','TheTitleThatIWant');
HTH

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!