From 2c0f51b31a3f32c091ae04632f7d8e424f734577 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 7 Nov 2013 13:19:39 -0800 Subject: [PATCH] Fix 0.0 value on axis to be 0.0. I recently saw cases where the %g format was cauing a value that should be 0.0 on the axis to appear as something insane like 5.58e-17. If the value is within a thousandth of a sub-step, (a sub-step is the space between two minor ticks on the axis), of 0.0 then force it to be truly 0.0. --- acre.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/acre.c b/acre.c index f46aebf..fac0a20 100644 --- a/acre.c +++ b/acre.c @@ -915,10 +915,14 @@ _draw_ticks (acre_t *acre, { PangoLayout *layout; int width, height; + double label_value; cairo_save (cr); - layout = _create_layout_printf (acre, "%g", t); + label_value = t; + if (fabs (label_value) < (sub_step / 1000.)) + label_value = 0.0; + layout = _create_layout_printf (acre, "%g", label_value); if (ticks == ACRE_TICKS_X) cairo_move_to (cr, t, acre->y_axis.view_min); -- 2.43.0