If you know from before the rough range of your data, you can just set the ylim:
plt.ylim([y_min, y_max])
A smart way of doing this would be to automatically infer the boundaries of your data from the vector you have (assuming it's called y):
y_min = min(y)
y_max = max(y)
offset = (y_max-y_min)*0.3 # To give us some leeway
plt.ylim([y_min-offset, y_max+offset])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.