2012-04-23 31 views
0

任何人都可以告訴我如何在字典中使用自定義破折號序列。我不能說跑,只有我不能(不是程序員)工作的事情是文檔= - (Matplotlib:如何在字典中設置破折號?

def lineCycler(): #must be invoked for every plot again to get the same results in every plot 
    #hasy="#7b9aae" 
    _styles = [{'color':'#b21a6a', 'ls':'-'}, 
       {'color':'#65a4cb', 'ls':'[5,2,10,5]'},# this shoul be some custom dash sequnece 
       {'color':'#22b27c', 'ls':'-.'}, 
       {'color':'k', 'ls':'--'} 
      ] 

    _linecycler=cycle(_styles) 
    return _linecycler 

回答

2

使用dashes關鍵字進行(和你需要的,而不是一個字符串列表):

def lineCycler(): 
    _styles = [{'color':'#b21a6a', 'ls':'-'}, 
       {'color':'#65a4cb', 'dashes':[5,2,10,5]}, 
       {'color':'#22b27c', 'ls':'-.'}, 
       {'color':'k', 'ls':'--'} 
      ] 

    _linecycler=cycle(_styles) 
    return _linecycler 
+0

非常感謝。我測試了一個(感覺像)萬套設置,但這是錯過了。 – 2012-04-24 14:41:34