将x轴设置为绘图甘特图

时间:2017-10-26 00:25:03

标签: python plot plotly

我是剧情的新手,我有一些使用start = int和finish = int(以抽象时间单位)的任务。但x轴默认为日期格式。我想以数字格式(0,1,2 ...)

设置x轴

这是我的代码:

    df=list(df.values())
    pprint(df)
    colors = ['#ff1919', '#0000ff']
    fig = ff.create_gantt(df, colors=colors, index_col='Resource', 
    reverse_colors=True, show_colorbar=True)
    py.plot(fig, filename='gantt-string-variable', world_readable=True)

df看起来像:

df=[{'Finish': 5, 'Resource': 'Red', 'Start': 0, 'Task': 'task1'},
 {'Finish': 13, 'Resource': 'Red', 'Start': 5, 'Task': 'task2'},
 {'Finish': 8, 'Resource': 'Blue', 'Start': 5, 'Task': 'task3'},
 {'Finish': 11, 'Resource': 'Blue', 'Start': 5, 'Task': 'task4'},
 {'Finish': 20, 'Resource': 'Red', 'Start': 13, 'Task': 'task5'},
 {'Finish': 19, 'Resource': 'Blue', 'Start': 13, 'Task': 'task6'},
 {'Finish': 24, 'Resource': 'Red', 'Start': 20, 'Task': 'task7'}]

任何建议!

1 个答案:

答案 0 :(得分:2)

fig['layout']['xaxis'].update({'type': None})之前将此行叫py.plot(fig, filename='gantt-string-variable', world_readable=True)