2

I want to plot values of a table for example:

table = {0.456, 0.7899, 1.3456, 9.8908}

But I want to Plot points (x,y) like:

(0,0.456), (1,0.7899),(2,1.3456),(3,9.8908)

And the ListPlot commend generates the plot for vaues of x from range {1,10}, so points like: (1,0.456),(2,0.7899),(3,1.3456)... How can I change to plot from $0$ points which I described?

Ziva
  • 817
  • 1
  • 6
  • 13
  • 1
    See DataRange option for listplot. – ciao Jan 09 '14 at 00:20
  • I was trying to use DataRange, but then I had a mess with the points and I never could achieve this points which I want – Ziva Jan 09 '14 at 00:22
  • ListPlot[Table[{i,i}, {i, 0, 10}]] – Dr. belisarius Jan 09 '14 at 00:24
  • @Ziva: Not sure what you mean - perhaps you can provide an example? For your OP example, ListPlot[Table[i, {i, 0, 10}], DataRange -> {0, 10}], e,g,, gives what you appear to be asking for. – ciao Jan 09 '14 at 00:25
  • @belisarius I wrote that Table[i,{i,0,10}] is just an easy example, because I wanted to post easier data instead the very complicated. But now I edited my post, so maybe you will see what I need. – Ziva Jan 09 '14 at 00:26
  • @rasher I edited my post, hope now it is more accurate – Ziva Jan 09 '14 at 00:27
  • 1
    Or, in your new example, ListPlot[table, DataRange -> {0, Length[table] - 1}] – ciao Jan 09 '14 at 00:29
  • @Nasser But I used table to generate this datas which are in my post. I can't use this what wrote Belisarius because then it's wrong and I don't have tha same data which I posted – Ziva Jan 09 '14 at 00:29
  • @rasher Yes, that is what I was looking for! Thank you! – Ziva Jan 09 '14 at 00:32
  • @ziva: Great. If you want, I'll make it an answer and you can mark it as such. Also, belisarius' answer does essentially the same thing, caveat if table is large his creates additional memory pressure. – ciao Jan 09 '14 at 00:34
  • @rasher Yes, you can make an answer and then I will mark it. Your answer was first and really helped me :) – Ziva Jan 09 '14 at 01:20

2 Answers2

5

This will do what you want:

ListPlot[table, DataRange -> {0, Length[table] - 1}]
ciao
  • 25,774
  • 2
  • 58
  • 139
3
table = {2, 4, 8, 16};
ListLinePlot[Transpose[{Range[0, Length@# - 1], #}]] &@table

Mathematica graphics

Or:

ListLinePlot[#, DataRange -> {0, Length@# - 1}] &@table
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • Thanks! Rasher helped me how to solve my problem, but your solution is also very nice! – Ziva Jan 09 '14 at 01:21