fix the value scale - ploot - simple plotting tools
(HTM) git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit eb816ab512727f55665f05809c78563ff93a94cc
(DIR) parent 2a69604bc0f075b85c3b6c1e4e60a455e09e8bc2
(HTM) Author: Josuah Demangeon <me@josuah.net>
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(-)
---
(DIR) 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;
}
}
}