I had similar issues. I solved it creating a slot "onBeforeReplot( )" which is connected to QQCustomPlot's Signal "beforeReplot()".
In the slot, first I obtain the QCustomPlot's pointer:
QCustomPlot *plot = dynamic_cast<QCustomPlot*>(QObject::sender() );
If the pointer is not NULL, the sender is a valid QCustomPlot and you could e.g. write some code like this:
plot->xAxis->setRange( computeValidRangeX( plot->xAxis->range() ) );
plot->yAxis->setRange( computeValidRangeY( plot->xAxis->range() ) );
to ensure the ranges are valid. The methods "computeValidRange*" do have the current range as input and give a valid range. In it you could set minimal or maximal values and a minimum span for the range.