Change y range to start from 0 with matplotlib

前端 未结 3 962
春和景丽
春和景丽 2020-12-08 09:43

I am using matplotlib to plot data. Here\'s a code that does something similar:

import matplotlib.pyplot as plt
f, ax = plt.subplots(1)
xdata = [1, 4, 8]
yda         


        
3条回答
  •  忘掉有多难
    2020-12-08 10:03

    Note that ymin will be removed in Matplotlib 3.2 Matplotlib 3.0.2 documentation. Use bottom instead:

    import matplotlib.pyplot as plt
    f, ax = plt.subplots(1)
    xdata = [1, 4, 8]
    ydata = [10, 20, 30]
    ax.plot(xdata, ydata)
    ax.set_ylim(bottom=0)
    plt.show(f)
    

提交回复
热议问题