When I show a ListPlot and a Plot for the same function the graph is wrong.

Show[Plot[x^3, {x, 0, Pi}] ,
ListPlot[Table[x^3, {x, 0.0, Pi, 0.1}],
DataRange -> {0, Pi}]]

The graphs are slightly off and I don’t understand why.

Can anyone help me understand what I have to do if I want the graphs to match perfectly?

The first point in your ListPlot is {0,0}, which is fine. The last point is {Pi, 3.1^3} instead of {Pi, Pi^3}, and while this might seem like a small difference, it’s noticeable with regard to the curve from Plot.

Two possible solutions are to either generate the points as {x,y} pairs, in which case you don’t need DataRange:

ListPlot[Table[{x, x^3}, {x, 0.0, Pi, 0.1}]]

or to use a setting for DataRange that accurately reflects the range of x-values for the data you’re plotting:

ListPlot[Table[x^3, {x, 0.0, Pi, 0.1}], DataRange -> {0, 3.1}]

Thanks Brett. I really appreciate the help.