如何在Pygal中改变笔画宽度?

时间:2015-03-25 08:08:20

标签: python pygal

在Pygal中,有没有办法改变笔画宽度(例如让它更厚)?

我在文档中找不到与此相关的任何内容。

1 个答案:

答案 0 :(得分:0)

to_dict类上有一个Style方法,对于创建自定义样式非常有帮助。

>>> 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'}
相关问题