From: Anamika on
Hello,

How can I plot several 2-d subplots, where the y limits are constant, but with varying x limits?

Thanks,
Mika
From: Jan Simon on
Dear Anamika!

> How can I plot several 2-d subplots, where the y limits are constant, but with varying x limits?

You can set the YLimMode and YLim properties:
set(AxisHandle, 'YLimMode', 'manual', 'YLim', [0, 10]);

Jan
From: us on
"Anamika " <Anamika.Darwin(a)gmail.com> wrote in message <hu9556$rp5$1(a)fred.mathworks.com>...
> Hello,
>
> How can I plot several 2-d subplots, where the y limits are constant, but with varying x limits?
>
> Thanks,
> Mika

one of the solutions

sh=nan(4,1);
for i=1:4
sh(i)=subplot(2,2,i);
line(1:4,rand(1,4));
end
set(sh,'ylim',[-1,2]);

us
From: Anamika on
Hi Jan,

Thank you for your reply. I think I can apply this; however instead of hard-coding the limits in the set command, can I load a vector that will contain the values for the limits? If yes, how can I do this?

I will have anything between 20 and 160 subplots depending on the problem that I work. I plan to plot using a for loop, getting the values for x & y for each subplot. And for each plot, I will need to pull the appropriate limit into the loop.


Much appreciate your help!
~Mika



"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hu97g6$6p0$1(a)fred.mathworks.com>...
> Dear Anamika!
>
> > How can I plot several 2-d subplots, where the y limits are constant, but with varying x limits?
>
> You can set the YLimMode and YLim properties:
> set(AxisHandle, 'YLimMode', 'manual', 'YLim', [0, 10]);
>
> Jan
From: Jan Simon on
Dear Mika!

> Thank you for your reply. I think I can apply this; however instead of hard-coding the limits in the set command, can I load a vector that will contain the values for the limits? If yes, how can I do this?

I'm not sure, if you mean this:
ylimit = [0, 10];
set(AxisH, 'YLim', ylimit);
??? Or:
ylimit = rand(160, 2);
for k = 1:160
AxisH = subplot(40, 40, k);
set(AxisH, 'YLim', ylimit(k, :));
end

BTW: The creation of 160 subplots is much faster if you avoid the command SUBPLOT, which searchs for overlapping existing axes objects.

Jan