fix the value scale - ploot - simple plotting tools | |
git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit eb816ab512727f55665f05809c78563ff93a94cc | |
parent 2a69604bc0f075b85c3b6c1e4e60a455e09e8bc2 | |
Author: Josuah Demangeon <[email protected]> | |
Date: Sun, 27 Jun 2021 01:25:05 +0200 | |
fix the value scale | |
Diffstat: | |
M ploot-braille.c | 8 +++++--- | |
1 file changed, 5 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/ploot-braille.c b/ploot-braille.c | |
@@ -68,12 +68,13 @@ adjust_scale(double *min, double *max, int rows) | |
dv = *max - *min; | |
+ step = 1; | |
if (dv > 1) { | |
for (double mant = 1;; mant *= 10) { | |
double *sc = scale; | |
for (; sc < scale + LEN(scale); sc++) { | |
step = mant * *sc; | |
- if (dv < (rows - 2) * step) | |
+ if (dv < rows * step) | |
goto end; | |
} | |
} | |
@@ -81,9 +82,10 @@ adjust_scale(double *min, double *max, int rows) | |
for (double mant = 1;; mant /= 10) { | |
double *sc = scale + LEN(scale) - 1; | |
for (; sc >= scale; sc--) { | |
- step = mant * *sc; | |
- if (dv > (rows - 2) * step) | |
+ double tmp = mant * *sc; | |
+ if (dv > rows * tmp) | |
goto end; | |
+ step = tmp; | |
} | |
} | |
} |