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

**URL:** <https://community.wolfram.com/t/when-i-show-a-listplot-and-a-plot-for-the-same-function-the-graph-is-wrong/381>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization\
**Created:** [August 14, 2013, 8:43pm UTC](https://community.wolfram.com/t/when-i-show-a-listplot-and-a-plot-for-the-same-function-the-graph-is-wrong/381 "2013-08-14T20:43:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wolfram3](https://avatars.discourse-cdn.com/v4/letter/w/ecd19e/32.png) [@wolfram3](https://community.wolfram.com/u/wolfram3)\
**Post date:** [August 14, 2013, 8:43pm UTC](https://community.wolfram.com/t/when-i-show-a-listplot-and-a-plot-for-the-same-function-the-graph-is-wrong/381/1 "2013-08-14T20:43:25Z")

</div>

```auto
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?

---

<div class="post-metadata">

**Author:** ![brettc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/brettc/32/39223_2.png) [@brettc](https://community.wolfram.com/u/brettc)\
**Post date:** [August 15, 2013, 2:56am UTC](https://community.wolfram.com/t/when-i-show-a-listplot-and-a-plot-for-the-same-function-the-graph-is-wrong/381/2 "2013-08-15T02:56:07Z")

</div>

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** :

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![wolfram3](https://avatars.discourse-cdn.com/v4/letter/w/ecd19e/32.png) [@wolfram3](https://community.wolfram.com/u/wolfram3)\
**Post date:** [August 16, 2013, 5:20pm UTC](https://community.wolfram.com/t/when-i-show-a-listplot-and-a-plot-for-the-same-function-the-graph-is-wrong/381/3 "2013-08-16T17:20:28Z")

</div>

Thanks Brett. I really appreciate the help.
