2015-04-01 101 views
0

我確定這是一個簡單的答案,但無法在任何地方找到。我想讓x軸讀取值爲2000,2001,2002,2003,2004,而不是2 x e ** 3。在X軸Matplotlib上更改數字格式

import numpy as np 
import matplotlib.pyplot as plt 

x = [2000, 2001, 2002, 2003, 2004] 
y = [2000, 2001, 2002, 2003, 2004] 

plt.xticks(np.arange(min(x), max(x)+1, 1.0)) 
plt.plot(x,y) 
plt.show() 

該代碼返回一個圖表,表示這樣的值。我該如何改變它?

enter image description here

@阿維納什·潘迪

enter image description here

回答

1

enter image description here 您可以使用

plt.xticks(np.arange(min(x), max(x)+1, 1.0), x) 

嘗試本作中,你的代碼空間已經有需要的只是標籤... 欲瞭解更多信息,請點擊這裏link

+0

出於某種原因,添加此線會使x軸消失,儘管它會在y軸對面移動一些刻度線。 – 2015-04-01 18:11:53

+0

可以顯示輸出... – 2015-04-01 18:13:03

+0

圖片在上面的問題 – 2015-04-01 18:23:11