Re: How to subtract two sets of data for a ListPlot

• To: mathgroup at smc.vnet.net
• Subject: [mg76721] Re: [mg76672] How to subtract two sets of data for a ListPlot
• From: János <janos.lobb at yale.edu>
• Date: Sat, 26 May 2007 04:37:00 -0400 (EDT)
• References: <200705251045.GAA08313@smc.vnet.net>

```On May 25, 2007, at 6:45 AM, chuck009 wrote:

> Hi all.  Suppose I've calculated two sets of lists of the form for
> example:
>
> list1={{1,1},{2,2},{3,3}};
>
> list2={{1,1},{2,4},{3,9}};
>
> What's an efficient way to create a third list with the same x-
> values but with the y-values subtracted
>
> newlist={{1,0},{2,-2},{3,-6}};
>
> I realize I can manually subtract them in a For-loop, but I'm sure
> a one-line command using Map or some other construct can be used as =

> well but can't figure it out.
>
> Thanks!

Here is a newbie approach:

In[5]:=
newlist = Table[
{list1[[i,1]],
list1[[i,2]] - list2[[i,
2]]}, {i, 1,
Length[list1]}]
Out[5]=
{{1, 0}, {2, -2}, {3, -6}}

J=E1nos

----------------------------------------------
Trying to argue with a politician is like lifting up the head of a
corpse.
(S. Lem: His Master Voice)

```

• Prev by Date: Re: exporting graphics
• Next by Date: Re: Stopping Automatic Animation in v6
• Previous by thread: Re: How to subtract two sets of data for a ListPlot
• Next by thread: Re: How to subtract two sets of data for a ListPlot