Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Subplot Error - Missing Graphs

Subject: Subplot Error - Missing Graphs

From: Mauricio Perillo

Date: 16 Nov, 2010 03:38:04

Message: 1 of 3

I am trying to make a subplot that is 6 by 5 with the following code

B = zeros(30,4);
a = ones(6,1); B(:,1) = [0*a;1/5*a;2/5*a;3/5*a;4/5*a];
a = [0;1/6;2/6;3/6;4/6;5/6]; B(:,2) = [a;a;a;a;a];
B(:,4) = 0.15; B(:,3) = 0.19;
clear a
 
for i = 1:30
            ImageName_temp = ['FileName' ' - ' num2str(i,'%03d')];
            h = subplot(6,5,i);
            text(.5,.5,ImageName_temp,'FontSize',14,'HorizontalAlignment','center')
            hold on
            set(gca,'xtick',[],'ytick',[])
            set(h,'position',B(i,:))
end

However, I am missing 1/2 of the plots.

I dont see what is theproblem with the logic but I get this plot

http://img690.imageshack.us/img690/6084/errorkt.jpg

Thanks

Subject: Subplot Error - Missing Graphs

From: Aurelien Queffurust

Date: 16 Nov, 2010 13:10:05

Message: 2 of 3

"Mauricio Perillo" <mperill2@illinois.edu> wrote in message <ibsuas$pf$1@fred.mathworks.com>...
> I am trying to make a subplot that is 6 by 5 with the following code
>
> B = zeros(30,4);
> a = ones(6,1); B(:,1) = [0*a;1/5*a;2/5*a;3/5*a;4/5*a];
> a = [0;1/6;2/6;3/6;4/6;5/6]; B(:,2) = [a;a;a;a;a];
> B(:,4) = 0.15; B(:,3) = 0.19;
> clear a
>
> for i = 1:30
> ImageName_temp = ['FileName' ' - ' num2str(i,'%03d')];
> h = subplot(6,5,i);
> text(.5,.5,ImageName_temp,'FontSize',14,'HorizontalAlignment','center')
> hold on
> set(gca,'xtick',[],'ytick',[])
> set(h,'position',B(i,:))
> end
>
> However, I am missing 1/2 of the plots.
>
> I dont see what is theproblem with the logic but I get this plot
>
> http://img690.imageshack.us/img690/6084/errorkt.jpg
>
> Thanks

It is the expected behavior. in the doc of subplots :
http://www.mathworks.com/help/techdoc/ref/subplot.html
you can read:
"If a subplot specification causes a new axis to overlap a existing axis, the existing axis is deleted "
 and it is what happens when your variable i equals 6 in your sample code.

To achieve what you need, you could just replace :
 h = subplot(6,5,i);
by
 h =axes;

Aurélien
http://blog.developpez.com/matlab4geek/

Subject: Subplot Error - Missing Graphs

From: Doug Hull

Date: 23 Nov, 2010 15:12:03

Message: 3 of 3

http://blogs.mathworks.com/videos/2010/11/22/subplot-vs-axes/

Doug

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us