4
$\begingroup$

I have the following data that I would like to plot using ListPlot.

{0.027010624472009, 0.02701062501084, 0.02701062521073, \
0.02701062530257, 0.02701062535098, 0.02701062537908, \
0.02701062539659, 0.02701062540811, 0.02701062541603, \
0.02701062595486, 0.02701062615475, 0.02701062669358, \
0.02701062689348, 0.02701062698531, 0.02701062703373, \
0.02701062706183, 0.02701062707934, 0.02701062709086, \
0.02701062709877, 0.02701062710441, 0.02701062710853, \
0.02701062711163, 0.02701062711401, 0.02701062711587}

But whenever I use ListPlot with PlotRange specified so that I am just within the range of the above data, I still get a flat line that tells me nothing. Is there a way to fix this? This is really important for me. Thanks for your help. I am attaching the result of ListPlot enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ You could plot the data minus their minimum or similar transformation. $\endgroup$ Apr 12 at 15:43
  • 1
    $\begingroup$ Using @b.gates.you.know.what suggestion, perhaps (data - Mean[data])/StandardDeviation[data] would give a plot with a nice range (showing how many standard deviations each point is from the mean of the dataset), and then just keep track of what the Mean and StandardDeviation shift/scaling factors are $\endgroup$
    – ydd
    Apr 12 at 15:46
  • 1
    $\begingroup$ ListPlot[d - Min[d]] will do what you want. $\endgroup$ Apr 12 at 16:59

3 Answers 3

4
$\begingroup$

Using b.gates comment

ListStepPlot[data - Min[data],
 Filling -> Axis,
 Mesh -> Full,
 MeshStyle -> Red]

enter image description here

$\endgroup$
3
$\begingroup$

As suggested by ydd

$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global`*"]

data = {0.027010624472009, 0.02701062501084, 0.02701062521073, 
   0.02701062530257, 0.02701062535098, 0.02701062537908, 0.02701062539659, 
   0.02701062540811, 0.02701062541603, 0.02701062595486, 0.02701062615475, 
   0.02701062669358, 0.02701062689348, 0.02701062698531, 0.02701062703373, 
   0.02701062706183, 0.02701062707934, 0.02701062709086, 0.02701062709877, 
   0.02701062710441, 0.02701062710853, 0.02701062711163, 0.02701062711401, 
   0.02701062711587};

{μ, σ} = (#[data] & /@ {Mean, StandardDeviation})

(* {0.0270106, 9.01769*10^-10} *)

data2 = (data - μ)/σ;

lp = ListPlot[data2,
   ColorFunction -> "Rainbow"];

yticks = ((Ticks /. AbsoluteOptions[lp, Ticks])[[2]]) /.
    {str_String?(StringLength[#] > 0 &) :> "μ+" <> str <> "σ"} /.
   {"μ+0.0σ" :> "μ", 
    str_String :> StringReplace[str, "+-" -> "-"]};

Show[lp, Ticks -> {Automatic, yticks},
 PlotRange -> All,
 PlotRangePadding -> Scaled[.006],
 PlotRangeClipping -> False]

enter image description here

$\endgroup$
2
$\begingroup$

One way is to plot small numbers by subtraction of a constant and relabeling the ticks to be the text of the correct numbers as follows. First let us give the number list a name, call it mat, then

ListPlot[mat - 0.027010624, PlotRange -> {{0, 25}, {0, 4.`*^-9}}, 
Ticks -> {Table[i, {i, 0, 24, 2}], 
 Table[{i, ToString[0.027010624`9 + i]}, {i, 0, 4.`9*10^-9, 0.5`9*10^-9]}]

Which yields,enter image description here

Why? ListPlotonly displays numbers to machine precision number display, which is only 6 places. Consequently it cannot display the three places beyond 0.0270106. However, you can make it display 9 significant figures by re-scaling the plot by subtracting something, in this case, 0.0270106240`9 which it would then display as zero on the $y$-axis, and then displaying that as a string which is literally "0.0270106240" and with incrementally larger string ticks to complete your desired incremental ticks on the $y$-axis.

The way this could be fixed in code mirrors the code above. That is, the software should extend virtual precision automatically as needed for tick marks and tick number display. Unfortunately, it doesn't do that automatically. This is a typical engineering mistake. Another example of that is to think that eight bit gray scale image display should be taken directly from the data, rather than buffering it, so if the actual data has 16 bits of gray scale, and the data is windowed to show 8 bits of that data, then only 4 bits gray scale are displayed out of 8, which makes an image look like a paint by numbers image with only 16 displayed gray levels.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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