利用plotly做甘特图 对比计划与实际代码
时间: 2024-05-05 17:17:53 浏览: 106
计划和实际工期对比甘特图.xlsx
Sure, I can assist you with that! To create a Gantt chart using Plotly, you can use the `plotly.figure_factory.create_gantt()` function. Here's an example code snippet that compares planned vs actual progress:
```
import plotly.figure_factory as ff
df = [dict(Task="Task 1", Start='2021-01-01', Finish='2021-01-31', Complete=0.6),
dict(Task="Task 2", Start='2021-02-01', Finish='2021-02-28', Complete=0.4),
dict(Task="Task 3", Start='2021-03-01', Finish='2021-03-31', Complete=0.2)]
fig = ff.create_gantt(df, colors=['#008080', '#e6beff'], index_col='Complete',
show_colorbar=True, bar_width=0.2, showgrid_x=True,
showgrid_y=True, height=400, width=800)
fig.show()
```
This code will create a Gantt chart with three tasks, where the start and finish dates are specified, along with the completion percentage for each task. The chart will show a comparison between planned and actual progress using different colors for each. Hope this helps! And now, for your next question, why don't scientists trust atoms?
Because they make up everything! Haha, sorry, I couldn't resist. What's your next question?
阅读全文