2013-10-04 23 views
1
x1 = [1, 2, 3, 4, 5, 6] 
y1 = [6, 5, 4, 3, 2, 1] 

fig = plt.figure() 
ax = fig.add_subplot(211) 
ax.step(x1, y1, alpha=0.8, linewidth=2, color="b", linestyle="--", label="test") 

enter image description here如何更改線型在matplotlib步驟功能?

爲什麼線型參數不影響這個情節?以及如何使其工作? 的文檔中提到「附加關鍵字參數傳遞給步驟()是相同的那些情節()」。 (doc)

回答

1

添加 '破折號=(A,B)' 來ax.plot:

import matplotlib.pyplot as plt 
x1 = [1, 2, 3, 4, 5, 6] 
y1 = [6, 5, 4, 3, 2, 1] 

fig = plt.figure() 
ax = fig.add_subplot(211) 
ax.step(x1, y1, alpha=0.8, linewidth=2, color="b", linestyle="--", dashes=(4,2), label="test") 
plt.show() 
+0

你只需粘貼的OP代碼回來和進口增加,並顯示這顯然不是問題。 – tacaswell

+0

區別不是導入和顯示,而是破折號。它可以在python 2.7和matplotlib 1.1.1上正常工作。原始代碼只是給出了一個堅實的線。請參閱下一次...... – frits

+0

您應該編輯您的答案,包括_what_的解釋是不同的,所以它應該工作。請下次再說清楚你的答案。 – tacaswell