# How to change step size of ListPlot

The command ListPlot will plot lists with a unit step. Is there any way to change the step size of this?

-
check the time-stamps of the answers. I am sure you are glad you switched to the MMA SE site:) –  kguler Feb 10 '12 at 0:02
Sure am! THank you so much! I hope to learn by self discovery, but you might see me again. Thank you for all your help! –  Edwin Feb 10 '12 at 1:23

Perhaps you are looking for DataRange?

SeedRandom[1];
dat = RandomReal[5, 20];
ListLinePlot[dat, DataRange -> {1, 5}]


-

Two approaches:

1. Use the option DataRange (in the Options section of ListPlot in the documentation center.

2. ListPlot also takes a list of x,y pairs. So another option is transforming your input data (a list of y values) to a list of x,y pairs

-
I prefer the second one myself; I am at least confident that points are being plotted, and not just data values. –  Ｊ. Ｍ. Feb 10 '12 at 0:24
@J.M, me too. Especially with irregularly-spaced multiple lists using DataRange is not any simpler. –  kguler Feb 10 '12 at 0:29

Lists don't save the value they have been generated with. Consider the example of plotting a sine using a discrete point set:

data = Table[Sin[2 Pi x], {x, 0, 1, 0.05}];
ListPlot[data]


Notice the nonsense values on the $x$ axis.

There are three possible solutions for this, all of which give the following plot as a result:

## Using DataRange to manually specify the domain of the data in ListPlot

data = Table[Sin[2 Pi x], {x, 0, 1, 0.05}];
ListPlot[data, DataRange -> {0, 2 Pi}]


The disadvantage of this approach is that the data range is not known to the plot, and it has to be entered by the user manually. If the data itself changes, the plot will still assume these manual numbers, even if the domain is now much larger (consider expanding the above table to run from 0 to 20).

## Embedding the data range into the list

data = {
Table[Sin[2 Pi x], {x, 0, 1, 0.05}],
DataRange -> {0, 2 Pi}
};
ListPlot @@ data


Disadvantage: the DataRange option is only useful for a couple of functions. When you're planning to further modify the data, you will always have to pay attention that data doesn't save the data on the first level, but on the second one of this nested list.

## Incorporating the x values when generating the data

data = Table[{2 Pi x, Sin[2 Pi x]}, {x, 0, 1, 0.05}];
ListPlot[data]


The disadvantage of this approach is of course a more complicated list structure, as well as about twice the amount of data.

-
If you know that the data is at equidistant places, you could just make a two-component list: data={Table[Sin[x],{x,0,2 Pi,Pi/10}],DataRange->{0,2 Pi}} and then ListPlot[data[[1]], data[[2]]] or even just ListPlot@@data. –  celtschk Feb 10 '12 at 16:35
@celtschk Thanks, I included it in my answer. –  David Feb 10 '12 at 17:30