Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: 20 images in 3x3 plot
Replies: 2   Last Post: Jan 10, 2013 3:00 AM

 Messages: [ Previous | Next ]
 ImageAnalyst Posts: 13,022 Registered: 12/26/06
Re: 20 images in 3x3 plot
Posted: Jan 3, 2013 8:24 PM

"Lim " <limhueynee@gmail.com> wrote in message <kc3eq7\$80b\$1@newscl01ah.mathworks.com>...
> I have 20 images and I want to put them in a 3x3 subplot in each figure, how to call up the new figure when the first figure is 'full'?
>
> nCol = 20;
> for k = 1:nCol
> C1 = original;
> C1(rgb_label ~= k) = 0;
> blah{k} = C1;
> end
>
> I am now using the painstaking subplot code:
> figure(1),subplot(3,3,1),imshow(blah{1});
> subplot(3,3,2),imshow(blah{2});
> ...
>

==================================================
Try this:

format longg;
format compact;
clc; % Clear command window.
workspace; % Make sure the workspace panel is showing.
fontSize = 25;

currentFigureNumber = 0; % Just for plot titles
for k = 1 : 12
% Determine the plot number.
plotNumber = mod(k+2, 3)+1;

% Open a brand new figure if necessary.
if plotNumber == 1
figure;
% Increment counter. Optional - Just for plot titles.
currentFigureNumber = currentFigureNumber + 1;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
end

% Make the subplot in the right place.
subplot(1, 3, plotNumber);

plot(rand(1,5), 'LineWidth', 2);
grid on;
caption = sprintf('Plot #%d on figure %d',...
plotNumber, currentFigureNumber);
title(caption, 'FontSize', 24);
end

Date Subject Author
1/3/13 Lim
1/3/13 ImageAnalyst
1/10/13 Lim