我有一个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
在这里,我使用了ax.set_xlim([0,1,0.001]),其中0.001是x轴之间的间距值。不幸的是,我遇到了一个错误。我想我做错了方法来设置那些东西
答案 0 :(得分:0)
正如我的评论中所述,set_xlim
不接受“步骤”参数。另外,我认为你想要的方法是set_xticks
,可以按如下方式使用:
In [13]: import numpy as np
...: ticks = np.arange(0, 2, 0.1)
...: ax.set_xticks(ticks)
...: fig
并给出以下结果: