[Fwd: Re: Difference between 2 lines and adaptative grid]

You have to interpolate the results to a common vector, and then perform
the difference. If you want to reproduce exactly the difference you can
see on-screen, then use a linear interpolation (cause the lines joining
successive points are straight, hence a linear interpolation - well,
assuming that your plot is in cartesian coordinates, else this becomes
more tricky), and map both set of results to the common vector
(list(x1)+list(x2)).sort() (remove duplicated values and reduce it to
the interval max(min(x1),min(x2)), min(max(x1),max(x2)) if you want to
be clean and safe...)

ยทยทยท

On Mon, 2005-08-29 at 17:39 +0200, Nicolas Girard wrote:

Hi all,

I apologize for beeing slightly off-topic with this question, but I couldn't
think about a better place to ask :-/

Consider two vectors x1 and y1. Using matplotlib, plot(x1,y1) will display the
line joining all points whose coordinates are (x1(i),y1(i))
Now, consider another couple of vectors x2 and y2.
Using plot(x1,y1,x2,y2) we are shown the 2 lines corresponding to (x1,y1) and
(x2,y2), and we can compare these two lines with the naked eye

My question is, how to do this quantitatively ? Is there a way of calculating
the difference between the two sets of points, and then plot this difference,
using matplotlib ? I mean, if the data was generated using a fixed grid, it
would be enough to plot (y2-y1) but with an adaptative grid, x1 and x2
differ. Do you know about a quick & dirty way to achieve this ?