5
$\begingroup$

I have a dataset like

data = {{-5., 1.00000000000000004968}, {-4.5, 1.00000000000000004510}, {-4., 1.00000000000000004200}, {-3.5, 1.00000000000000004144}, {-3., 1.00000000000000004012}, {-2.5, 1.00000000000000003979}, {-2., 1.00000000000000004132}, {-1.5, 1.00000000000000004208}, {-1., 1.00000000000000004284}, {-0.5, 1.00000000000000004726}, {0., 1.00000000000000004284}, {0.5, 1.00000000000000004350}, {1., 1.00000000000000004312}, {1.5, 1.00000000000000004073}, {2., 1.00000000000000003956}, {2.5, 1.00000000000000004256}, {3., 1.00000000000000003917}, {3.5, 1.00000000000000004538}, {4., 1.00000000000000004671}, {4.5, 1.00000000000000004685}, {5., 1.00000000000000004719}} 

However ListPlot[data] just gives a bunch of datapoints with constant ordinate. How can I visualize the small variations of the ordinates?

$\endgroup$
5
  • $\begingroup$ Try ListPlot[data] $\endgroup$ Commented Sep 15, 2016 at 8:36
  • 4
    $\begingroup$ Have you tried searching the documentation for "plot data"? What did you find? $\endgroup$ Commented Sep 15, 2016 at 8:36
  • $\begingroup$ At risk of missing the original problem, I've edited this question. If I distorted your intent, feel free to roll back. $\endgroup$ Commented Sep 15, 2016 at 10:17
  • 4
    $\begingroup$ I don't think this should closed as a simple mistake. There is a real, non-trivail issue being raised. $\endgroup$ Commented Sep 15, 2016 at 12:06
  • 1
    $\begingroup$ I expected ListPlot[data, PlotRange -> MinMax /@ Transpose@data] to set the y-axis appropriately, but it turns out it just completely ignores it (presumably because it ignores a PlotRange where the two endpoints are "equal") $\endgroup$ Commented Sep 15, 2016 at 12:16

2 Answers 2

9
$\begingroup$

I suggest modifying the y-coordinates by subtracting of 1.0, while compensating for that in the list plot by adding 1.0 to frame tick labels for the y-coordinates.

data = {{-5., 1.00000000000000004968}, {-4.5, 1.00000000000000004510}, {-4., 1.00000000000000004200}, {-3.5, 1.00000000000000004144}, {-3., 1.00000000000000004012}, {-2.5, 1.00000000000000003979}, {-2., 1.00000000000000004132}, {-1.5, 1.00000000000000004208}, {-1., 1.00000000000000004284}, {-0.5, 1.00000000000000004726}, {0., 1.00000000000000004284}, {0.5, 1.00000000000000004350}, {1., 1.00000000000000004312}, {1.5, 1.00000000000000004073}, {2., 1.00000000000000003956}, {2.5, 1.00000000000000004256}, {3., 1.00000000000000003917}, {3.5, 1.00000000000000004538}, {4., 1.00000000000000004671}, {4.5, 1.00000000000000004685}, {5., 1.00000000000000004719}}; dataX = data[[All, 1]]; dataY = data[[All, 2]] - 1; plotPts = Transpose[{dataX, dataY}]; divisions = FindDivisions[MinMax[dataY], 5] // N 

{3.75*10^-17, 4.*10^-17, 4.25*10^-17, 4.5*10^-17, 4.75*10^-17, 5.*10^-17}

ListPlot[plotPts, Axes -> False, Frame -> True, FrameTicks -> {{{#, Row[{"1 + ", #}]} & /@ divisions, None}, Automatic}] 

plot

$\endgroup$
3
  • 2
    $\begingroup$ Turns out, this is a more interesting question, than one would realize at face value. I guess, the real question is "how to plot at better than machine precision?" +1 for going to so much trouble $\endgroup$ Commented Sep 15, 2016 at 11:40
  • $\begingroup$ @LLlAMnYP. The real problem is that Plot, in the end, will always have to draw at machine precision. So the data and the plot scales have to be manipulated to accommodate that fact. $\endgroup$ Commented Sep 15, 2016 at 11:49
  • $\begingroup$ I would simply draw dataY and emphasize (e.g., by appropriate labeling the vertical axis) that this is $y-1$. In my opinion it's easier to compreend the plot that way; one thinks of it as the magnitude of variations around 1 and can focus on the $10^{-17}$ parts, not on realizing how high above the zero each point is. $\endgroup$ Commented Sep 15, 2016 at 16:01
5
$\begingroup$

Looks like a pretty boring plot, unless you do something to visualize those very small variations in the ordinate. Maybe this can point you in the right direction:

data = {{-5., 1.00000000000000004968}, {-4.5, 1.00000000000000004510}, {-4., 1.00000000000000004200}, {-3.5, 1.00000000000000004144}, {-3., 1.00000000000000004012}, {-2.5, 1.00000000000000003979}, {-2., 1.00000000000000004132}, {-1.5, 1.00000000000000004208}, {-1., 1.00000000000000004284}, {-0.5, 1.00000000000000004726}, {0., 1.00000000000000004284}, {0.5, 1.00000000000000004350}, {1., 1.00000000000000004312}, {1.5, 1.00000000000000004073}, {2., 1.00000000000000003956}, {2.5, 1.00000000000000004256}, {3., 1.00000000000000003917}, {3.5, 1.00000000000000004538}, {4., 1.00000000000000004671}, {4.5, 1.00000000000000004685}, {5., 1.00000000000000004719}}; ListPlot[{#[[1]], Log@#[[2]]}& /@ data, Joined -> True] 

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks dionys. This will help me. $\endgroup$ Commented Sep 15, 2016 at 9:05
  • $\begingroup$ Thank you all. All answers are helping me. $\endgroup$ Commented Sep 15, 2016 at 16:28
  • $\begingroup$ Suppose my data Set contains more than 500 points it is not working.@ m_goldberg, Corey 979. $\endgroup$ Commented Sep 15, 2016 at 16:56

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.