change default value and logic for detecting ymin and ymax