Skip to content
Snippets Groups Projects
Commit 09249d00 authored by Andrew E. Torda's avatar Andrew E. Torda
Browse files

Fiddled again, to remove extreme cases of over-generous lower bounds.

parent 45478b61
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,7 @@ func Tickpos(x []float64) (AxisDscrpt, error) {
return axisDscrpt, errors.New("too few data points")
}
xmin, xmax := minMax(x)
realxmin := xmin
if xmax-xmin < math.SmallestNonzeroFloat32 {
return axisDscrpt, errors.New("max - min too small")
}
......@@ -157,10 +158,18 @@ func Tickpos(x []float64) (AxisDscrpt, error) {
default: // a tight upper bound
}
// That was Heckbert style. Now, let us do the R thing and check if the lower
// bound was too generous. Problem is, that I think when we are near zero,
// we should leave the lower bound at zero.
toomuch := realxmin -xmin
howmany := toomuch / delta
if howmany >= 2 { // This is too much whitespace
xmin = xmin + math.Floor(howmany) * delta
}
rnge = xmax - xmin // Min & max have been rounded, so recalculate the range
ntick = int(math.Round((rnge / delta) + 1))
a := math.Log10(delta)
_ = a
var prcsn int = 0
if delta < 1 {
prcsn = int(math.Floor(math.Log10(delta)))
......
......@@ -13,7 +13,7 @@ var test1set = []struct {
x []float64
ad ad // really an AxisDscrpt
}{
{f64{18, 19}, ad{15, 19, .1, 1}},
{f64{18, 19}, ad{18, 19, .1, 1}},
{f64{-0.01, 0.05}, ad{-0.01, 0.05, 0.01, 2}},
{f64{1, 2}, ad{1, 2, 0.1, 1}},
{f64{1, 100}, ad{0, 100, 10, 0}},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment