简体   繁体   English

如何在Pygal中更改笔划宽度?

[英]How to change stroke width in Pygal?

In Pygal, is there a way to change the stroke width (make it thicker for example)? 在Pygal中,是否可以更改笔触宽度(例如使其变粗)?

I didn't find anything related to that in the docs. 我在文档中没有找到与此相关的任何内容。

There is a to_dict method on the Style class that is very helpful for creating custom styles. 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'}

Here's how you might create a custom style with a thick stroke width. 这是创建笔触粗细的自定义样式的方法。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM