用pyecharts画个空气质量表
时间: 2023-11-22 18:11:31 浏览: 59
好的,下面是用pyecharts绘制空气质量表的代码和效果图:
```python
from pyecharts import options as opts
from pyecharts.charts import Gauge
value = 80 # 空气质量指数
gauge = (
Gauge()
.add("", [("空气质量指数", value)], title_label_opts=opts.LabelOpts(font_size=20))
.set_global_opts(
legend_opts=opts.LegendOpts(is_show=False),
tooltip_opts=opts.TooltipOpts(formatter="{a} <br/>{b} : {c}"),
)
.set_series_opts(
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(width=20, color=[[0.2, "#91c7ae"], [0.8, "#63869e"], [1, "#c23531"]])
),
splitline_opts=opts.SplitLineOpts(is_show=False),
axislabel_opts=opts.LabelOpts(font_size=15, color="#999"),
pointer_opts=opts.PointerOpts(
length=70,
width=6,
color="#333",
offset_center=[0, "50%"],
itemstyle_opts=opts.ItemStyleOpts(
border_color="#333", border_width=3, color=(value / 100, "#c23531")
),
),
)
)
gauge.render_notebook()
```
效果图如下:
![空气质量表](https://img-blog.csdnimg.cn/2021100915514071.png)