# HG changeset patch # User Rik # Date 1685555075 25200 # Node ID 32313c5e1bfc0a0786494707f12ec9460d9c79f3 # Parent 8b795293c050b653de088041ebbc04cae4637287 Don't use 2-digit exponent format for ticklabels when unnecessary. * graphics.cc (calc_ticklabels): New boolean variable is_2digit_exp. Cycle through ticklabel values using log10 to determine if maximum exponent is greater than or equal to 10. As soon as this condition is found set is_2digit_exp to true and break out of loop. Within ticklabel formatting loop, only print leading '0' if is_2digit_exp is true and the current exponent to be printed is less than 10. diff -r 8b795293c050 -r 32313c5e1bfc libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Wed May 31 10:12:26 2023 -0700 +++ b/libinterp/corefcn/graphics.cc Wed May 31 10:44:35 2023 -0700 @@ -7943,14 +7943,16 @@ { double significand; double exponent; - double exp_max = 0.0; - double exp_min = 0.0; + bool is_2digit_exp = false; for (int i = 0; i < values.numel (); i++) { - double exp = std::log10 (values(i)); - exp_min = std::min (exp_min, exp); - exp_max = std::max (exp_max, exp); + double exp = std::abs (std::log10 (values(i))); + if (exp >= 10.0) + { + is_2digit_exp = true; + break; + } } for (int i = 0; i < values.numel (); i++) @@ -7969,7 +7971,7 @@ exponent = std::floor (std::log10 (-values(i))); else exponent = std::floor (std::log10 (values(i))); - significand = values(i) * std::pow (10., -exponent); + significand = values(i) * std::pow (10.0, -exponent); os.precision (5); os.str (""); @@ -7986,7 +7988,7 @@ os << '-'; exponent = -exponent; } - if (exponent < 10. && (exp_max > 9 || exp_min < -9)) + if (exponent < 10.0 && is_2digit_exp) os << '0'; os << exponent << '}';