I have the following code to plot a gantt chart in plotly:
import datetime
import pandas
import plotly.express as px
task_list = [{
'Task': 'T-3', 'y': 0, 'Start': datetime.date(2022, 2, 24),
'Finish': datetime.date(2022, 3, 17), 'Status': 'Scheduled'}, {
'Task': 'SNP-350', 'y': 1, 'Start': datetime.date(2022, 2, 24),
'Finish': datetime.date(2022, 2, 25), 'Status': 'Backlog'}, {
'Task': 'RD-6687', 'y': 2, 'Start': datetime.date(2022, 3, 18),
'Finish': datetime.date(2022, 4, 8), 'Status': 'Selected'}, {
'Task': 'RD-6643', 'y': 3, 'Start': datetime.date(2022, 2, 24),
'Finish': datetime.date(2022, 3, 17), 'Status': 'Scheduled'}, {
'Task': 'SNP-337', 'y': 4, 'Start': datetime.date(2022, 5, 21),
'Finish': datetime.date(2022, 5, 23), 'Status': 'Backlog'}, {
'Task': 'SNP-352', 'y': 5, 'Start': datetime.date(2022, 2, 26),
'Finish': datetime.date(2022, 2, 28), 'Status': 'Clarification'}, {
'Task': 'SNP-239', 'y': 6, 'Start': datetime.date(2022, 5, 24),
'Finish': datetime.date(2022, 5, 25), 'Status': 'Selected'}]
df = pandas.DataFrame(task_list)
fig = px.timeline(df, x_start="Start", x_end="Finish", y="y",
# color="Status",
)
fig.show()
This gives me a gantt chart as expected:
However, if I now include the line that is commented out in the code above, i.e. color the bars in the gantt chart according to their status, it messes up the height of the different bars:
So the colors are shown as expected but it seems the height of the different bars is now not limited by the neighboring bar but only by the neighboring bar with the same color. How can I add the colors to the gantt chart but keep the height of the bars as it is without colors?