使用python的xaxis matplotlib中值之间的间距值

2024-10-04 01:28:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个FPR和TPR图。在这里我想问如何计算x轴之间的间距值。我的代码如下:

  In [85]:

    fig, ax = plt.subplots(figsize=(8,6), dpi=80)
    ax.plot(x_iter1_TF , y_iter1_TF, label='Iter1', marker='o')
    ax.plot(x_iter5_TF, y_iter5_TF ,label='Iter5',  marker='v')
    ax.plot(x_iter10_TF, y_iter10_TF , label='Iter10',  marker='x')
    ax.plot(x_iter25_TF, y_iter25_TF , label='Iter20',  marker='+')
    ax.plot(x_iter50_TF, y_iter50_TF , label='Iter50',marker='D')
    ax.legend(loc=1); # upper left corner
    ax.set_xlabel('FPR')
    ax.set_ylabel('TPR')
    ax.set_xlim([0,1, 0.001])
    ax.set_ylim([0,1, 0.001])
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    <ipython-input-85-87b9ef379a9b> in <module>()
          8 ax.set_xlabel('FPR')
          9 ax.set_ylabel('TPR')
    ---> 10 ax.set_xlim([0,1, 0.001])
         11 ax.set_ylim([0,1, 0.001])

    C:\Python27\lib\site-packages\matplotlib\axes\_base.pyc in set_xlim(self, left, right, emit, auto, **kw)
       2524 
       2525         if right is None and iterable(left):
    -> 2526             left, right = left
       2527 
       2528         self._process_unit_info(xdata=(left, right))

    ValueError: too many values to unpack

{1美元^

在这里我用过斧头套件([0,1,0.001]),其中0.001是x轴之间的间距值。不幸的是,我遇到了一个错误。我想我把那些东西弄错了


Tags: rightplottfaxleftmarkerlabel间距