2014-05-23 147 views
0

雙對數情節我只是想暗算「A對B」在日誌日誌縮放情節,但我得到一個錯誤。Python的 - 情節與matplotlib

import matplotlib.pyplot as plt 

a = [7255.151855, 231.589661, 9.365415, 0.55364, 1.5001, 0.006408, 0.001204, 0.000842] 
b = [0.212399, 0.393191, 0.727874, 1.347436, 2.494368, 4.617561, 8.548006, 15.824027] 

CyclesPerBlock = 219397 
LoadAmplitude = 4990 

a = [x*CyclesPerBlock for x in a] 
b = [y*LoadAmplitude for y in b] 

fig = plt.plot 
fig.set_xscale("log") 
fig.set_yscale("log") 
fig.set_xlim(1e-3, 1e4) 
fig.set_ylim(1e-1, 1e3) 
fig.set_aspect(1) 
fig.set_title("Calculation Results") 

fig.plot(a, b, "o-") 
plt.draw() 
plt.show() 
+0

你有一個答案,但最好是張貼問題時,包括完整的回溯。最好還是發佈生成問題所需的_minimum_數量的代碼。 – tacaswell

回答

4

你必須先創建AxesSubplot對象,然後用它來繪製:

fig = plt.figure() 
ax = fig.add_subplot(111) 
ax.set_xscale("log") 
ax.set_yscale("log") 
ax.set_xlim(1e-3, 1e4) # <-- check this as pointed out by @tillsten 
ax.set_ylim(1e-1, 1e3) # <-- 
ax.set_aspect(1) 
ax.set_title("Calculation Results") 

ax.plot(a, b, "o-") 
+1

另外你的xlim和ylim是錯的。 – tillsten