我有这个图表,显示如下内容:
plt.plot(valueX, scoreList)
plt.xlabel("Score number") # Text for X-Axis
plt.ylabel("Score") # Text for Y-Axis
plt.title("Scores for the topic "+progressDisplay.topicName)
plt.show()
valueX = [1, 2, 3, 4],scoreList = [5, 0, 0, 2]
我想让比例尺按照1递增,无论'scoreList'中的值为何。目前我的x轴按照0.5递增而不是1。
我该如何设置才能使其只按照1递增?
plt.gca().set_xscale('linear')
。否则,当你写成plt.axes.Axes
时,会出现AttributeError: 'function' object has no attribute 'Axes'
的错误;当你写成set_xscale(1, 'linear')
时,会出现TypeError: set_xscale() takes 2 positional arguments but 3 were given
的错误。 - coldfix