Setting Axis Range on a Matplotlib Chart

Python

Here we set the axis range to 40-52 for the X axis, 0-4000 for the primary y axis and 0-1200 for the secondary y axis.

 1|  ax.set_xlim(40,52) #Set range of X axis
 2|  ax.set_ylim(0,4000) # Set range of primary y axis
 3|  ax2.set_ylim(0,1200) # Set range of secondary y axis
Did you find this snippet useful?

Sign up for free to to add this to your code library