Reputation: 311
So I have a 3x3 array of subplots. I know how to get a title on each one of them, and I know how to get a "super title" using the suptitle function over the whole thing, but I can't figure out how to get titles to only show up over each column. I also want to do a similar thing with the rows. Think hip, knee, ankle across the top, then angular velocity, torque, and power down the left side. Thoughts?
Upvotes: 3
Views: 19675
Reputation: 686
As noted in the comments to the other answer, you can do this using titles and y-labels in individual subplots.
Use title
on the top row of plots to produce column labels.
For row labels, take advantage of the (possibly undocumented?) feature that allows you to have multi-row labels, thus:
ylabel({'Row label' 'Actual y-label'});
It's a nasty kludge, and it's a PITA if your subplots are generated within a loop, but until/unless Mathworks give us a proper to way to do this it's the best that I know of.
Upvotes: 1
Reputation: 13610
You can use text
to label the columns and rows.
subplot(2,2,1)
title('a')
h1 = text(-0.25, 0.5,'row 1');
set(h1, 'rotation', 90)
text(0.35,1.2,'column 1');
subplot(2,2,2)
title('b')
text(0.35,1.2,'column 2');
subplot(2,2,3)
title('c')
h = text(-0.25, 0.5, 'row 2');
set(h, 'rotation', 90)
subplot(2,2,4)
title('d')
The position of text will have to be adjusted based on the x and y range of your plots.
Upvotes: 6