Home >Backend Development >Python Tutorial >How to Set Custom Y-Axis Limits in Matplotlib?
Adjusting Y-Axis Limits in Matplotlib
You have expressed difficulty in setting the y-axis limits of a matplotlib plot to the desired values of 20 and 250.
To rectify this situation, utilize the following technique:
Start by retrieving the current axis instance:
ax = plt.gca()
Subsequently, employ the 'set_ylim' method to establish the y-axis limits:
ax.set_ylim([20, 250])
By incorporating these enhancements into your code, you should successfully specify the y-axis limits as intended.
The above is the detailed content of How to Set Custom Y-Axis Limits in Matplotlib?. For more information, please follow other related articles on the PHP Chinese website!