2015-03-25 39 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'}