Re: DataRange
- To: mathgroup at smc.vnet.net
- Subject: [mg83553] Re: DataRange
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 22 Nov 2007 05:02:47 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <fi0q05$6ib$1@smc.vnet.net>
thomas wrote: > Hello Mathgroup, > > I use ListLinePlot to plot some data that has been downsampled. In > order to get the original time-range of the data represented correctly > on the x-axis, I use DataRange->{1,Length-of-original-data}, which > works just beautifully. > > Now imagine I want to plot 2 sets of data with different original > length, both have been downsampled. As far as I know, I cannot use the > DataRange option anymore, because it will equally apply to both > curves, therefore either stretching or compressing one curve relative > to the other. > > Example: > data1 = Range[5];(*imagine original length is 50*) > data2 = .5 Range[10];(*imagine original length is 100*) > ListLinePlot[{data1, data2}, Frame -> True, AspectRatio -> Full, > PlotLabel -> "Correct relative scale of data"] > ListLinePlot[{data1, data2}, DataRange -> {1, 50}, Frame -> True, > AspectRatio -> Full, PlotLabel -> "data2 is compressed"] > ListLinePlot[{data1, data2}, DataRange -> {1, 100}, Frame -> True, > AspectRatio -> Full, PlotLabel -> "data1 is streched"] > > > Is there an easy way to do this, short of creating specific {x,y}- > pairs for each data point in each of the curves? > > As a suggestion to WRI I would propose that one should be able to give > multiple inputs to DataRange, to handle these issues, similar to way > the option PlotStyle->...handles the directives given to it. The following should be quite close to what you are looking for. data1 = Range[5];(*imagine original length is 50*) data2 = .5 Range[10];(*imagine original length is 100*) g1 = ListLinePlot[{data1}, DataRange -> {1, 50}, Axes -> False, Frame -> True, AspectRatio -> 1/2]; g2 = ListLinePlot[{data2}, DataRange -> {1, 100}, Axes -> False, Frame -> True, AspectRatio -> 1/2]; Show[{g2, g1}] (* Note that g2 -- largest data range == comes first *) Regards, -- Jean-Marc