MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


Hi,

when you just want to plot the data and your x-values are 1,2,3..
then you can simply write

(list1 - list2)[[All, 2]]

and you get the subtracted y-values.
ListPlot will do the rest because it assumes that your x-values are in the
order you had.

Cheers
Patrick

Am 25.05.2007, 12:45 Uhr, schrieb chuck009 <dmilioto at comcast.com>:

> 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!



-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/


  • Prev by Date: Re: How to subtract two sets of data for a ListPlot
  • Next by Date: Re: How to subtract two sets of data for a ListPlot
  • 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