Reputation: 23
I have used the following loop to get subplots:
for j=1:19;
Aj=B(j,:);
subplot(5,4,j);
plot(Aj,h)
end
For all these subplots, I need to have only one x-label and one y-label. How to do this? Also how to insert legend to all the subplots?
Upvotes: 2
Views: 1719
Reputation: 19689
You can use suplabel
from the FileExchange to have combined x and y label for all subplots.
Example:
subplot(1,2,1);
plot(randperm(40)); hold on; plot(randperm(40)); %Plotting some random data
legend('show') %To show the legend
subplot(1,2,2);
plot(randperm(40)); hold on; plot(randperm(40)); %Plotting some random data
legend('show') %To show the legend
%Using suplabel from the FileExchange to give a single x and y label for all subplots
suplabel('Combined X label','x');
suplabel('Combined Y label','y');
Output:
Sometimes you have to maximize the figure window to see the xlabel when using suplabel
.
Upvotes: 2