142

y軸の上限を「auto」に設定したいのですが、y軸の下限を常にゼロにしたいと思います。'auto'と'autorange'を試しましたが、うまくいかないようです。前もって感謝します。

これが私のコードです:

import matplotlib.pyplot as plt

def plot(results_plt,title,filename):

    ############################
    # Plot results

    # mirror result table such that each parameter forms an own data array
    plt.cla()
    #print results_plt
    XY_results = []

    XY_results = zip( *results_plt)

    plt.plot(XY_results[0], XY_results[2], marker = ".")

    plt.title('%s' % (title) )
    plt.xlabel('Input Voltage [V]')
    plt.ylabel('Input Current [mA]')

    plt.grid(True)
    plt.xlim(3.0, 4.2)  #***I want to keep these values fixed"
    plt.ylim([0, 80]) #****CHANGE**** I want to change '80' to auto, but still keep 0 as the lower limit 
    plt.savefig(path+filename+'.png')
4

6 に答える 6

138

leftあなたはちょうどまたはrightに渡すことができますset_xlim

plt.gca().set_xlim(left=0)

y軸には、bottomまたはtop:を使用します。

plt.gca().set_ylim(bottom=0)
于 2012-07-31T16:58:23.690 に答える
47

xlim制限の1つを設定するだけです:

plt.xlim(left=0)
于 2015-09-17T15:16:03.767 に答える
4

@silvio にポイントを追加するだけです: axis を使用して のようにプロットする場合figure, ax1 = plt.subplots(1,2,1)。その後ax1.set_xlim(xmin = 0)も機能します!

于 2016-06-08T07:09:51.017 に答える