diff --git a/pub/plot/axis.cpp b/pub/plot/axis.cpp
index d405f2a8f09bd183766140b1ebd4a79ab289946e..3f03b3187500a8f19076d128b5312835af6b105e 100644
--- a/pub/plot/axis.cpp
+++ b/pub/plot/axis.cpp
@@ -166,7 +166,8 @@ void CAxis::set_rounded_limits( double _inf, double _sup )
             if(sup<0 && sup2>0) sup2 = 0;
             if(inf2<0 && inf>0) inf2 = 0;
             mydigits += 0.5;
-        } while (!((inf2<inf) && (sup<sup2)));
+            printf("DEB [%g,%g] -> [%g,%g] (%g)\n", inf, sup, inf2, sup2, mydigits);
+        } while ( !((inf2<inf) && (sup<sup2)) && mydigits<18 );
     } else { // log limits
         double ratio = sup / inf;
         double margin = exp( relmargin*log(ratio) );
@@ -174,7 +175,7 @@ void CAxis::set_rounded_limits( double _inf, double _sup )
             sup2 = triv::round_decimal( sup*margin, mydigits );
             inf2 = triv::round_decimal( inf/margin, mydigits );
             mydigits += 0.5;
-        } while ( !((inf2<inf) && (sup<sup2)) );
+        } while ( !((inf2<inf) && (sup<sup2)) && mydigits<18 );
     }
     set_limits( inf2, sup2 );
 }