plots icon indicating copy to clipboard operation
plots copied to clipboard

Axis auto-centering and numerical precision

Open ocramz opened this issue 9 years ago • 1 comments

series_w

The above time series was obtained from a non-Gaussian distribution; the vertical axis is not centered at 0 but rather at that tiny value (something ^ -18). Are the two things related and can the axis centering be rounded either by hand or automatically ?

ocramz avatar Dec 17 '16 20:12 ocramz

I guess the easiest way to centre the y axis is to manually set yMin ?= -x and yMax ?= x for some x. In your case x=0.04 should do it.

Or do you mean you want the number displayed to be 0.0? There's two functions that determine the numbers displayed.

You could manually set either to get it to display 0.0 exactly.

I'm not sure the best way to deal with this case automatically. You could do something adhoc like map (\x -> if x < 1e-5 * abs (b - a) then 0 else x) ticks (where a and b are the bounds of the axis) to set values very close to zero and much smaller than the data range to exactly zero. But it's not perfect.

Another option is to calculate the majorTicksFunction using Rational so we get exact values.

cchalmers avatar Dec 18 '16 17:12 cchalmers