# Align x axises with data vectors of different size

Hi
I display two data vectors : the first is in the subplot 2,1,1 and the second in the subplot 2,1,2. Each of the data vectors have an x vector of dates to display values on x axis.
The 2 data vectors are correlated in time and I want to show the correlation.

But the two data vectors are not aligned as I wanted them to be since the data vector of subplot 2,1,2 have less element than the other one.

I can’t use the same x vector for both curves since it would force me to add empty values in the second data vector. And I don’t want to do that since it would add useless points in my curve.

So I need to find a way to allow me to align both data vectors on the different subplots without adding point to the data vector with a smaller number of elements.

Thanks
Johan

Does this do what you want?

ax1 = subplot(211)
ax1.plot(x1, y1)
ax2 = subplot(212, sharex=ax1)
ax2.plot(x2, y2)

ditto for sharey if you want to share the same y axes...

I

···

On Tue, Jun 10, 2008 at 8:51 AM, Johan Mazel <johan.mazel@...287...> wrote:

Hi
I display two data vectors : the first is in the subplot 2,1,1 and the
second in the subplot 2,1,2. Each of the data vectors have an x vector of
dates to display values on x axis.
The 2 data vectors are correlated in time and I want to show the
correlation.

But the two data vectors are not aligned as I wanted them to be since the
data vector of subplot 2,1,2 have less element than the other one.

I can't use the same x vector for both curves since it would force me to add
empty values in the second data vector. And I don't want to do that since it
would add useless points in my curve.

So I need to find a way to allow me to align both data vectors on the
different subplots without adding point to the data vector with a smaller
number of elements.

This is exactly what I wanted.
Thanks a lot.
I just wanted to know wether it was possible to add a little margin for the y axes because I can’t see the highest point of the curve since it’s on the edge of the subplot.
Anyway, thanks a lot for the good work.
Johan

2008/6/10 John Hunter <jdh2358@…287…>:

···

On Tue, Jun 10, 2008 at 8:51 AM, Johan Mazel <johan.mazel@…287…> wrote:

Hi

I display two data vectors : the first is in the subplot 2,1,1 and the

second in the subplot 2,1,2. Each of the data vectors have an x vector of

dates to display values on x axis.

The 2 data vectors are correlated in time and I want to show the

correlation.

But the two data vectors are not aligned as I wanted them to be since the

data vector of subplot 2,1,2 have less element than the other one.

I can’t use the same x vector for both curves since it would force me to add

empty values in the second data vector. And I don’t want to do that since it

would add useless points in my curve.

So I need to find a way to allow me to align both data vectors on the

different subplots without adding point to the data vector with a smaller

number of elements.

Does this do what you want?

ax1 = subplot(211)

ax1.plot(x1, y1)

ax2 = subplot(212, sharex=ax1)

ax2.plot(x2, y2)

ditto for sharey if you want to share the same y axes…

I

Yes, just set the xlim or ylim as desired

xlim(-5,5)
ylim(-6,10)

We should consider fix the autoscaling so that tthe default view lim
are always open intervals that contain the data.

JDH

···

On Tue, Jun 10, 2008 at 10:32 AM, Johan Mazel <johan.mazel@...287...> wrote:

This is exactly what I wanted.
Thanks a lot.
I just wanted to know wether it was possible to add a little margin for the
y axes because I can't see the highest point of the curve since it's on the
edge of the subplot.
Anyway, thanks a lot for the good work.

John Hunter wrote:

We should consider fix the autoscaling so that tthe default view lim
are always open intervals that contain the data.

This has been on my mental list for a long time. I will look into it.

Eric

Anyway guys, thanks a lot for the fast answer and all the good work you’re doing. Johan

2008/6/10 Eric Firing <efiring@…202…>:

···

John Hunter wrote:

We should consider fix the autoscaling so that tthe default view lim

are always open intervals that contain the data.

This has been on my mental list for a long time. I will look into it.

Eric