2024年python制作仪表盘图

=========

from pyecharts import options as opts

from pyecharts.charts import Gauge

c = (

Gauge()

.add(

“业务指标”,

[(“完成率”, 55.5)],

split_number=20,

axisline_opts=opts.AxisLineOpts(

linestyle_opts=opts.LineStyleOpts(

color=[(0.3, “#00CDCD”), (0.7, “#CDBE70”), (1, “#00EE00”)], width=30

)

),

detail_label_opts=opts.LabelOpts(formatter=“{value}”),

)

.set_global_opts(

title_opts=opts.TitleOpts(title=“Gauge-分割段数-Label”),

legend_opts=opts.LegendOpts(is_show=False),

)

)

c.render_notebook()

如果想让仪表盘的刻度变成5,那么我们可以把它分成20份(split_number=20)

四、改变仪表盘的大小

==========

from pyecharts import options as opts

from pyecharts.charts import Gauge

c = (

  • 24
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python中有多种生成仪表盘的工具,其中比较流行的是使用Python的Dash框架和Plotly库。Dash是一个基于Flask的Python Web框架,它提供了一种简单的方式来构建交互式Web应用程序,而Plotly则是一个数据可视化库,可以用来创建各种类型的表,包括仪表盘。 使用Dash和Plotly创建仪表盘的步骤如下: 1. 安装Dash和Plotly库。 2. 创建一个Dash应用程序。 3. 在应用程序中定义一个布局,可以使用Dash提供的HTML和Core组件来构建布局。 4. 创建一个回调函数,用来更新仪表盘的数据和布局。 5. 使用Plotly创建仪表盘,并将其添加到应用程序的布局中。 6. 运行应用程序,可以通过Web浏览器访问仪表盘。 下面是一个简单的例子,展示了如何使用Dash和Plotly创建一个仪表盘: ```python import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go app = dash.Dash() app.layout = html.Div( children=[ html.H1(children='Sales Dashboard'), dcc.Graph( id='example-graph', figure={ 'data': [ go.Indicator( mode='number+delta', value=1000, delta={'reference': 800}, gauge={'axis': {'visible': False}}, domain={'row': 0, 'column': 0} ), go.Indicator( mode='number+delta', value=120, delta={'reference': 80}, gauge={'axis': {'visible': False}}, domain={'row': 0, 'column': 1} ) ], 'layout': { 'grid': {'rows': 1, 'columns': 2}, 'template': {'data': {'indicator': [{'title': {'text': 'Total Sales'}}, {'title': {'text': 'Profit Margin'}}]}}, 'margin': {'l': 10, 'r': 10, 't': 50, 'b': 10} } } ) ] ) if __name__ == '__main__': app.run_server(debug=True) ``` 在这个例子中,我们首先导入了Dash、HTML、Core和Plotly库。然后创建了一个Dash应用程序,并定义了一个布局,其中包含一个标题和一个包含两个仪表盘指标的表。每个指标都使用go.Indicator函数创建,并设置了相应的值、参考值和样式。最后,我们使用dcc.Graph函数将这个表添加到布局中,并运行应用程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值