我想要繪製在matplotlib一些數據顯示的實驗性功能的結果如下:Matplotlib X-標籤數座標
xvalues = [2, 4, 8, 16, 32, 64, 128, 256]
yvalues = [400139397.517, 339303459.4277, 296846508.2103, 271801897.1163,
295153640.7553, 323820220.6226, 372099806.9102, 466940449.0719]
我想這繪製在對數刻度,使其更容易可視化等方面都寫了下面的代碼:
import matplotlib.pyplot as plt
def plot_energy(xvalues, yvalues):
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.scatter(xvalues, yvalues)
ax.plot(xvalues, yvalues)
ax.set_xscale('log')
ax.set_xticklabels(xvalues)
ax.set_xlabel('RUU size')
ax.set_title("Energy consumption")
ax.set_ylabel('Energy per instruction (nJ)')
plt.show()
但是,你可以看到我的xlabels不會出現,因爲我想他們所看到以下
如果我刪除線ax.set_xticklabels(xvalues)
然後我得到了下面的結果,這不是我想無論是什麼:
我是在x軸上繪製出正確的價值觀一定的幫助非常感謝!
在此先感謝。