setting y-axis limit in matplotlib

Get current axis via plt.gca(), and then set its limits:

ax = plt.gca()
ax.set_xlim([xmin, xmax])
ax.set_ylim([ymin, ymax])

Leave a Comment