This will fail when being computed outside of the loop since `ymin` etc. might be `None`.