2
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ See DataRange option for listplot. $\endgroup$ – ciao Jan 9 '14 at 0:20
  • $\begingroup$ 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 $\endgroup$ – Ziva Jan 9 '14 at 0:22
  • $\begingroup$ ListPlot[Table[{i,i}, {i, 0, 10}]] $\endgroup$ – Dr. belisarius Jan 9 '14 at 0:24
  • $\begingroup$ @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. $\endgroup$ – ciao Jan 9 '14 at 0:25
  • 1
    $\begingroup$ Or, in your new example, ListPlot[table, DataRange -> {0, Length[table] - 1}] $\endgroup$ – ciao Jan 9 '14 at 0:29
5
$\begingroup$

This will do what you want:

ListPlot[table, DataRange -> {0, Length[table] - 1}]
$\endgroup$
3
$\begingroup$
table = {2, 4, 8, 16};
ListLinePlot[Transpose[{Range[0, Length@# - 1], #}]] &@table

Mathematica graphics

Or:

ListLinePlot[#, DataRange -> {0, Length@# - 1}] &@table
$\endgroup$
  • $\begingroup$ Thanks! Rasher helped me how to solve my problem, but your solution is also very nice! $\endgroup$ – Ziva Jan 9 '14 at 1:21

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.