3
$\begingroup$

I have data tuples, and I want to visualize them in an "overview" in a single plot with ListLinePlot. Example data:

data = {{-0.390974, -0.158722}, {-0.0113731, -0.555487}, {-0.336282, -0.711334}, 
        {-0.192636, -0.381761}, {-0.0910332, -0.367015}, {-0.239589, -0.460568}, 
        {-0.149918, -0.522732}, {-0.336194, -0.319426}, {-0.0599809, -0.21935}, 
        {-0.156575, -0.531545}, {1.29412, -0.399341}, {0.568567, -0.328689}, 
        {-0.110572, -0.191875}, {-0.156716, -0.375925}, {1.04408, -0.24397}}

Some data goes up (e.g. the first entry), some goes down (the second entry). However, ListLinePlot[data] interprets the tuples as x-y-pairs, rather than as 2-entry-time-series. How do I plot that data as many 2-point-lines in a single plot? It works with higher dimensional data (3 entries and more), but not for tuples.

$\endgroup$

closed as off-topic by MarcoB, Dr. belisarius, m_goldberg, user9660, Karsten 7. Nov 17 '15 at 6:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Dr. belisarius, m_goldberg, Community, Karsten 7.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try ListLinePlot[Transpose@data, PlotRange -> All] $\endgroup$ – eldo Nov 16 '15 at 20:24
  • $\begingroup$ @eldo No... that plots 2 long lines. I want many short lines with just 2 points. $\endgroup$ – Thomas Nov 16 '15 at 20:27
  • $\begingroup$ have a look at Partition $\endgroup$ – george2079 Nov 16 '15 at 20:34
  • $\begingroup$ @george2079 I am really interested in the data format that needs to be parsed into ListLinePlot to achieve this easily. I know how to do it if I explicitly supply the two x-coordinates (1,2) for the two data points. Then, the data looks like this: {{{1,x1},{2,y1}},{{1,x2},{2,y2}},...}. I also know how to do this. But that seems like a hack and too complicated. Isn't there a simpler way? $\endgroup$ – Thomas Nov 16 '15 at 20:39
  • $\begingroup$ Perhaps ListLinePlot[data, DataRange -> All]? $\endgroup$ – kglr Nov 16 '15 at 20:55
5
$\begingroup$
ListLinePlot[data, DataRange -> All]

Mathematica graphics

$\endgroup$
  • $\begingroup$ When you extend the plot range beyond 2, a horizontal line is drawn using this solution. $\endgroup$ – Jack LaVigne Dec 30 '15 at 16:02
3
$\begingroup$

A few alternatives:

 ListLinePlot[{{1, #[[1]]}, {2, #[[2]]}} & /@ data]

 ListLinePlot[Transpose[{{1, 2}, #}] & /@ data]

 ListLinePlot[MapIndexed[{Last@#2, #} &, data, {2}]]
$\endgroup$

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