1
$\begingroup$

I am plotting a list using the following command:

ListPlot[Table[f[x], {x, 0.01, 1.5, 0.015}]]

In the plot, the x-axis ranges from 0 to 100, which is the total number of points. How can I change the x-axis scale as to show the range of the variable x instead?

$\endgroup$
2
$\begingroup$

You need the option DataRange:

f = Sin;
ListPlot[Table[f[x], {x, 0.01, 1.5, 0.015}], DataRange -> {0.01, 1.5}]

Mathematica graphics

Alternatively, as suggested in a comment by @tchronis,

ListPlot[Table[{x, f[x]}, {x, 0.01, 1.5, 0.015}]] 
| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ ListPlot[Table[{x, f[x]}, {x, 0.01, 1.5, 0.015}]] will work too. This can help you work with parametric function too like ListPlot[Table[{x[t], y[t]}, {t, 0.01, 1.5, 0.015}]] $\endgroup$ – tchronis Feb 25 '17 at 20:55

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