setting y-axis limit in matplotlib

后端 未结 9 1725
自闭症患者
自闭症患者 2020-11-22 15:42

I need help with setting the limits of y-axis on matplotlib. Here is the code that I tried, unsuccessfully.

import matplotlib.pyplot as plt

plt.figure(1, fi         


        
9条回答
  •  太阳男子
    2020-11-22 16:30

    One thing you can do is to set your axis range by yourself by using matplotlib.pyplot.axis.

    matplotlib.pyplot.axis

    from matplotlib import pyplot as plt
    plt.axis([0, 10, 0, 20])
    

    0,10 is for x axis range. 0,20 is for y axis range.

    or you can also use matplotlib.pyplot.xlim or matplotlib.pyplot.ylim

    matplotlib.pyplot.ylim

    plt.ylim(-2, 2)
    plt.xlim(0,10)
    

提交回复
热议问题