如何在Pygal中更改描边宽度

3
在 Pygal 中,是否有一种方法可以改变描边的粗细(例如使其更粗)?
我在文档中没有找到相关的内容。

也许你需要这个设置:http://www.pygal.org/zh/latest/api/pygal.config.html?highlight=stroke_style#pygal.config.Config.width - Alexander Fedotov
2个回答

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'}

0
尝试在stroke_style上执行以下操作。
chart.add("Title", [], stroke_style={'width': 5})

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接