Skip to content

Instantly share code, notes, and snippets.

@hbshrestha
Created May 16, 2022 14:27
Show Gist options
  • Save hbshrestha/5c7128993c940a6cd89cc72261a64fe3 to your computer and use it in GitHub Desktop.
Save hbshrestha/5c7128993c940a6cd89cc72261a64fe3 to your computer and use it in GitHub Desktop.
waterfall chart 2
fig = go.Figure()
fig.add_trace(go.Waterfall(x = [["Initial","Short-term measure","Short-term measure",
"Short-term measure","Short-term measure","Short-term measure",
"Intermediate", "Long-term measure","Long-term measure",
"Long-term measure","Final"],
df["Values"]],
y = df["kWh"],
measure = df["measure"].tolist(),
base = 0, #by default
#get dotted line as connector
connector = {"line":{"dash":"dot"}},
textposition = "outside",
text = df["kWh"].tolist(),
orientation = "v",
decreasing = {"marker":{"color":"Maroon", "line":{"color":"red", "width":2}}},
increasing = {"marker":{"color":"Teal", "line":{"color":"Aquamarine","width": 3}}},
totals = {"marker":{"color":"deep sky blue", "line":{"color":"blue", "width":3}}}
))
fig.update_layout(title = "My electricity saving plan for next six months",
height = 600,
width = 800)
#Set y-limit
fig.update_yaxes(range = (0, 200), title = "kWh")
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment