Zer*_*uno 5 python visualization gantt-chart plotly
在项目管理中,甘特图可让您在时间线上查看项目的组件,例如在Plotly 中。在 Python 上下文中,如何最好在此图形上有一条线来指示该时间线中的当前日期,即今天的日期?在 Plotly 上下文中,有些形状可以将细线绘制为形状,但我无法将其应用于时间序列/甘特图,并且在视觉上似乎缺乏,因为它没有超出图形空间(即它不跨越轴)并且没有标签......
使用 Plotly 4.9.0,可以使用形状成功扩展文档(链接)中的标准时间线示例,正如您所提到的:
# plot standard Plotly Gantt example from docs
from pandas import pd
import plotly.express as px
import plotly.offline as py
df = pd.DataFrame([
dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28'),
dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')
])
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task")
fig.update_yaxes(autorange="reversed")
# add vertical line indicating specific date (e.g. today)
today = '2009-04-20'
fig.update_layout(shapes=[
dict(
type='line',
yref='paper', y0=0, y1=1,
xref='x', x0=today, x1=today
)
])
fig.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
672 次 |
| 最近记录: |