Indicator
A gauge chart (or speedometer chart) shows a single value against a range, typically used in dashboards for KPIs. Use the Indicator class from plotly.graph_objects with mode = "gauge+number".
import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
mode = "gauge+number",
value = 68,
gauge = dict(axis = dict(range = [0, 100]))))
fig.show()
Colored steps
Divide the gauge into colored ranges with gauge.steps, a list of dicts each with a range and a color.
import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
mode = "gauge+number",
value = 68,
gauge = dict(
axis = dict(range = [0, 100]),
bar = dict(color = "#4C72B0"),
steps = [dict(range = [0, 50], color = "#DEEBF7"),
dict(range = [50, 80], color = "#9ECAE1")])))
fig.show()
Threshold
Mark a target value with gauge.threshold, drawn as a thin line across the gauge.
import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
mode = "gauge+number",
value = 68,
gauge = dict(
axis = dict(range = [0, 100]),
bar = dict(color = "#4C72B0"),
threshold = dict(line = dict(color = "#C44E52", width = 4),
value = 90))))
fig.show()
Add mode = "gauge+number+delta" and a delta dict with a reference value to show the difference from a previous period, colored green or red depending on the direction.
import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
mode = "gauge+number+delta",
value = 68,
delta = dict(reference = 60),
gauge = dict(axis = dict(range = [0, 100]))))
fig.show()
Title and number suffix
Add a title dict for a label above the gauge, and a number dict with suffix (or prefix) to format the displayed value, for example as a percentage.
import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
mode = "gauge+number",
value = 68,
title = dict(text = "Server load"),
number = dict(suffix = "%"),
gauge = dict(axis = dict(range = [0, 100]))))
fig.show()
See also