diff --git a/lib/graphlib.php b/lib/graphlib.php
index <HASH>..<HASH> 100644
--- a/lib/graphlib.php
+++ b/lib/graphlib.php
@@ -1159,7 +1159,9 @@ class graph {
         if ($max < 0) $factor = - pow(10, (floor(log10(abs($max))) + $resolution) );
         else $factor = pow(10, (floor(log10(abs($max))) - $resolution) );
       }
-      $factor = round($factor * 1000.0) / 1000.0; // To avoid some wierd rounding errors (Moodle)
+      if ($factor > 0.1) { // To avoid some wierd rounding errors (Moodle)
+        $factor = round($factor * 1000.0) / 1000.0; // To avoid some wierd rounding errors (Moodle)
+      } // To avoid some wierd rounding errors (Moodle)
 
       $max = $factor * @ceil($max / $factor);
       $min = $factor * @floor($min / $factor);
graphlib: NOBUG previous Moodle-specific hack had a bug when y_max was very small. This would round, e.g. <I>^-5 to 0 which would break the axis.