Reputation: 35
I was creating a Gantt chart for my school project and while changing the color scheme of the bars I used the following line
chart.update_layout(title_font_size=42, font_size=10, title_font_family="Proxima Nova", color_continuous_scale=[(0, "red"), [0.5, "yellow", (1, "green")]])
and the error it is showing is
ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'color' and all the properties of plotly Bad property path: colour_continuous_scale
Upvotes: 1
Views: 2751
Reputation: 31166
color_continuous_scale
is a parameter to plotly expressupdate_layout()
you need to use graph objects parameter structure. Hence coloraxis={"colorscale":[...])
import plotly.express as px
import pandas as pd
df = pd.DataFrame(
[
dict(Task="Job A", Start="2009-01-01", Finish="2009-02-28", Completion_pct=50),
dict(Task="Job B", Start="2009-03-05", Finish="2009-04-15", Completion_pct=25),
dict(Task="Job C", Start="2009-02-20", Finish="2009-05-30", Completion_pct=75),
]
)
fig = px.timeline(
df,
x_start="Start",
x_end="Finish",
y="Task",
color="Completion_pct",
color_continuous_scale=[(0, "pink"), (0.5, "blue"), (1, "purple")],
)
fig.update_yaxes(autorange="reversed")
fig.update_layout(
title_text="Demo",
title_font_size=42,
font_size=10,
title_font_family="Proxima Nova",
coloraxis={"colorscale": [(0, "red"), (0.5, "yellow"), (1, "green")]},
)
Upvotes: 2