How to add figure title and axes labels for multiple plots?

I have plotted multiple plots in a single figure in matlab. Now i want to add figure title and axes (X, Y) labels. How can i do that.
I have tried with the following codes, however the problem is that they (tile and labels) only appears at the last plot instead of showing for the whole figure. Any idea or codes please!
if true
Input = xlsread('Data.xlsx');
for ii = 1:29
subplot(6,5,ii)
scatter(Input(:,1),Input(:,ii+1));
hold on
end
title('Multiple scatter plot of all simulated reff values from various input combinations');
xlabel('association');
ylabel('Effective radius in micrometer');
end

 Accepted Answer

Whatever you want to have on every axis, just move it inside the for loop, like so
% if true % what is the point of this?
Input = xlsread('Data.xlsx');
for ii = 1:29
subplot(6,5,ii)
scatter(Input(:,1),Input(:,ii+1));
% hold on % you don't need to hold on
title('Multiple scatter plot of all simulated reff values from various input combinations');
xlabel('association');
ylabel('Effective radius in micrometer');
end
% end

4 Comments

"if true" appears in this question post forum in the code, not in my original code.
Thanks for your answer, however the output shows all plot's titles and labels. But i want to show only single title on the top and one common X axis label and one common Y axis label. what code i have to write for that purpose?
I see... That is a little more difficult. What I can come up with is: Make your subplots, then create another, large axis. Make it invisible and move it to the background, but label and title the large axis. Like so:
f1 = figure
bkclr = get(f1,'Color') % The figure's background color
for ii=1:29 % Now plot your stuff.
subplot(6,5,ii);
scatter(Input(:,1),Input(:,ii+1));
end
bkax = axes; % this creates a figure-filling new axes
set(bkax,'Xcolor',bkclr,'Ycolor',bkclr,'box','off','Color','none') % make it 'disappear'
title('Title')
xlabel('My Xlabel','Color','k')
ylabel('My Ylabel','Color','k')
uistack(bkax,'bottom'); % this moves it to the background.
Many thanks for your codes and concept.
When i run above code (which you provide) i get following error message from matlab:
??? Error using ==> set
Ambiguous property found.
Object Name : axes
And most importantly, nothing can be seen in the output figure.
Is there maybe a variable named axes in your workspace? I am not getting any errors when I run the above. Run
whos axes
does that display anything?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!