5
$\begingroup$

I have two data lists and would like to plot them versus each other.

list1 = Get["http://pastebin.com/raw/Y9FFBzV5"];
list2 = Get["http://pastebin.com/raw/UjWXjgEL"];

The problem is they are of different length:

Dimensions[list1]
{4882}

Dimensions[list2]
{1392}

I would like to "stretch" list2 to the same length as list1, so that missing data should be interpolated.

UPDATE:

In the plot the minimum point should be {list1[[1]],list2[[1]]}. The maximum point should be (after data processing of list2): {list1[[4882]],list2[[4882]]}

What do I have to do?

$\endgroup$
  • 1
    $\begingroup$ ListLinePlot[{list1, list2}, DataRange -> {0, 100}], see DataRange $\endgroup$ – Jason B. Feb 10 '17 at 15:00
  • $\begingroup$ @lio There are two issues here. Would you like to plot them at the same graph, or one against the other (in this case in what order). The second issue is your "stretching" therm. Do you want to extrapolate missing points (of vector 2) or add points in between existing points and interpolate them. Or in other words, do terminal points of list1 correspond to terminal points of list2 $\endgroup$ – ercegovac Feb 10 '17 at 15:02
  • $\begingroup$ @ercegovac: I want not make two curves, the lists shoudl be plotted against each other, list1 as the horizontal axes and list2 as vertical axis. $\endgroup$ – lio Feb 10 '17 at 15:08
  • $\begingroup$ @lio You did not answer the second part of the question. Interpolation (adding points between existing points) or extrapolation beyond one of the terminal points. $\endgroup$ – ercegovac Feb 10 '17 at 15:13
  • 4
    $\begingroup$ ListLinePlot[Thread[{list1, ArrayResample[list2, Length@list1]}]] $\endgroup$ – Jason B. Feb 10 '17 at 15:14
7
$\begingroup$

Jason. B. has answered to my problem.

His solution is:

ListLinePlot[Thread[{list1, ArrayResample[list2, Length@list1]}], 
 Frame -> True, FrameLabel -> {{"list2", ""}, {"list1", ""}}] 

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.