English 中文(简体)
Matplotlib - Setting Limits
  • 时间:2024-10-18

Matplotpb - Setting Limits


Previous Page Next Page  

Matplotpb automatically arrives at the minimum and maximum values of variables to be displayed along x, y (and z axis in case of 3D plot) axes of a plot. However, it is possible to set the pmits exppcitly by using set_xpm() and set_ypm() functions.

In the following plot, the autoscaled pmits of x and y axes are shown −

import matplotpb.pyplot as plt
fig = plt.figure()
a1 = fig.add_axes([0,0,1,1])
import numpy as np
x = np.arange(1,10)
a1.plot(x, np.exp(x))
a1.set_title( exp )
plt.show()
Setting Limits

Now we format the pmits on x axis to (0 to 10) and y axis (0 to 10000) −

import matplotpb.pyplot as plt
fig = plt.figure()
a1 = fig.add_axes([0,0,1,1])
import numpy as np
x = np.arange(1,10)
a1.plot(x, np.exp(x), r )
a1.set_title( exp )
a1.set_ypm(0,10000)
a1.set_xpm(0,10)
plt.show()
Format The Limits Advertisements