比较(八)利用python绘制指示器
指示器(Indicators)简介
指示器是一系列相关图的统称,主要用于突出展示某一变量的实际值与目标值的差异,例如常见的数据delta、仪表盘、子弹图、水滴图等。
快速绘制
-
基于plotly
更多用法可参考Indicators in Python
import plotly.graph_objects as go fig = go.Figure() # 自定义仪表盘 fig.add_trace(go.Indicator( domain = { 'row': 0, 'column': 0}, value = 450, mode = "gauge+number+delta", title = { 'text': "Speed"}, delta = { 'reference': 380}, gauge = { 'axis': { 'range': [None, 500]}, 'steps' : [ { 'range': [0, 250], 'color': "lightgray"}, { 'range': [250, 400], 'color': "gray"}], 'threshold' : { 'line': { 'color': "red", 'width': 4}, 'thickness': 0.75, 'value': 490}})) # 自定义子弹图 fig.add_trace(go.Indicator( domain = { 'x': [0.05, 0.5], 'y': [0.15, 0.35]}, mode = "number+gauge+delta", value = 180, delta = { 'reference': 200}, gauge = { 'shape': "bullet", 'axis': { 'range': [None, 300]}, 'threshold': { 'line': { 'color': "black", 'width': 2}, 'thickness': 0.75, 'value': 170}, 'steps': [ { 'range': [0, 150], 'color': "gray"}, { 'range': [150, 250], 'color': "lightgray"}], 'bar': { 'color': "black"}})) # 基本delta fig.add_trace