2015-03-25 53 views
1

在Pygal中,有沒有辦法改變筆畫的寬度(例如使它更粗)?如何在Pygal中更改筆畫寬度?

我沒有在文檔中找到與此相關的任何內容。

+0

也許你需要此設置:http://www.pygal.org/en/latest/api/pygal.config.html?highlight=stroke_style#pygal.config.Config.width – 2015-11-18 17:31:29

回答

0

Style類有一個to_dict方法,對創建自定義樣式非常有幫助。

>>> CleanStyle.to_dict() 
{'opacity': '.8', 'foreground': 'rgba(0, 0, 0, 0.9)', 'plot_background': 'rgba(240, 240, 240, 0.7)', 'stroke_style': 'round', 'foreground_light': 'rgba(0, 0, 0, 0.9)', 'transition': '250ms', 'foreground_dark': 'rgba(0, 0, 0, 0.5)', 'stroke_dasharray': '0,0', 'opacity_hover': '.9', 'stroke_width': 1.0, 'colors': ('rgb(12,55,149)', 'rgb(117,38,65)', 'rgb(228,127,0)', 'rgb(159,170,0)', 'rgb(149,12,12)'), 'background': 'transparent', 'font_family': 'monospace'} 

下面介紹瞭如何創建粗筆觸寬度的自定義樣式。

>>> from pygal.style import Style, CleanStyle 
>>> style_arg = CleanStyle.to_dict() 
>>> style_arg['stroke_width']=10 
>>> HeavyCleanStyle = Style(**style_arg) 
>>> HeavyCleanStyle.to_dict() 
{'opacity': '.8', 'foreground': 'rgba(0, 0, 0, 0.9)', 'plot_background': 'rgba(240, 240, 240, 0.7)', 'stroke_style': 'round', 'foreground_light': 'rgba(0, 0, 0, 0.9)', 'transition': '250ms', 'foreground_dark': 'rgba(0, 0, 0, 0.5)', 'stroke_dasharray': '0,0', 'opacity_hover': '.9', 'stroke_width': 10.0, 'colors': ('rgb(12,55,149)', 'rgb(117,38,65)', 'rgb(228,127,0)', 'rgb(159,170,0)', 'rgb(149,12,12)'), 'background': 'transparent', 'font_family': 'monospace'}