Discussion:
Problem in imagesc with Subplot
(too old to reply)
nim
2004-09-08 18:34:59 UTC
Permalink
Hi,

I would appreciate if anyone helps me. I am plotting several sets of
data in the SAME figure(with the same X and Y axes). The following
one works fine:

for I=1:P
hold on;
imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));
colorbar
Ylabel('Freqency');
Xlabel('Time in minutes')
end
hold off;

but when I use subplot it does not work. Every time, only last set of
data is plotted, and not others.

for I=1:P
hold on;
SUBPLOT(2,2,1),imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));
colorbar
Ylabel('Freqency');
Xlabel('Time in minutes')
14:15)),'/',num2str(date_time(18:19)) ])
end
hold off;

It seems to me that "hold on" is not working with subplot. Could
anyone please suggest me anything?

Thanks in advance.
Nim
nim
2004-09-08 18:42:01 UTC
Permalink
Please avoid the 7th line in the second loop. it is a part of title
command, somehow escaped while deleting it. And P =10.

Thanks again
Nim
Post by nim
Hi,
I would appreciate if anyone helps me. I am plotting several sets of
data in the SAME figure(with the same X and Y axes). The following
for I=1:P
hold on;
imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));
colorbar
Ylabel('Freqency');
Xlabel('Time in minutes')
end
hold off;
but when I use subplot it does not work. Every time, only last set of
data is plotted, and not others.
for I=1:P
hold on;
SUBPLOT(2,2,1),imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));
colorbar
Ylabel('Freqency');
Xlabel('Time in minutes')
end
hold off;
It seems to me that "hold on" is not working with subplot. Could
anyone please suggest me anything?
Thanks in advance.
Nim
Bryan Smith
2004-09-08 21:29:40 UTC
Permalink
nim wrote:
<SNIP wants to use subplot in a for loop

Hi,

Replace
SUBPLOT(2,2,1),imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));

with
SUBPLOT(5,2,i),imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));

In <subplot>, the syntax subplot(m,n,p) breaks your figure into
m rows and n columns. p (not to be confused with your P) is the
linear index into the subplot matrix. In the example I wrote above,
you would generate a figure with 10 plots: 5 rows of 2 columns. The
indexing of p would be like this:

1 2
3 4
5 6

and so on.
In your case, you will always need to know the magnitude of P in
deciding how to break up your figure into subplots. Sorry for any
confusion of P with p... just convention.

have fun!
Bryan
nim
2004-09-09 15:49:55 UTC
Permalink
Hi Bryan,

Thankyou very much for your suggestion. It was useful to me. However,
still I have some problems. In my case, there will be six subplots (3
columns and 2 rows as you explained), and each subplot will show data
from six different heights. Now if we consider one subplot, it will
show one week data at particular height(say 80km). I have data in 3D
array. So I used "For Loop" to plot each day's data at 80km with
"hold on" command. But my figure shows the final day data only (7th
day), and not showing 1-6 days data. When I use just plot command
with out subplot, the above plan works.

for I=1:7
hold on;
SUBPLOT(2,2,1),imagesc(I,time_frq(:,1,I),time_frq(:,2,I));
colorbar
Ylabel('Freqency');
Xlabel('Time in minutes')
end
hold off;

According to above coding, everytime it should be ploted at the same
possition (2,2,1), but since the X-axis varys with loop, it would be
able to see all the data from day-1 to day -7. As I mentioned in
above, the above coding plots only the 7th day data. That is, I think
the "hold on" not working. I have tried to move "hold on" to
different lines, but no improvement.

Thanks again, and sorry for the confustion.
Nim
Post by Bryan Smith
<SNIP wants to use subplot in a for loop
Hi,
Replace
SUBPLOT(2,2,1),imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));
with
SUBPLOT(5,2,i),imagesc(time(I),time_frq(:,1,I),time_frq(:,2,I));
In <subplot>, the syntax subplot(m,n,p) breaks your figure
into
m rows and n columns. p (not to be confused with your P) is the
above,
you would generate a figure with 10 plots: 5 rows of 2 columns.
The
1 2
3 4
5 6
and so on.
In your case, you will always need to know the magnitude of P in
deciding how to break up your figure into subplots. Sorry for any
confusion of P with p... just convention.
have fun!
Bryan
Loading...