Edit layout of plotly Gantt Chart based on DataFrame

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

I'm trying to layout my Gantt Chart created with plotly and found some nice inspiration HERE. I use a DataFrame that looks like this:

           Task year                    ehead        Start  Resource    exity       Finish 0   Afghanistan 1946    Mohammad Zahir Shah     1946-11-08         5    2008    1953-09-20 1   Afghanistan 1953    Sardar Mohammad Daoud   1953-09-20         3    2008    1963-03-01 2   Afghanistan 1963    Mohammad Zahir Shah     1963-03-01         5    2008    1973-07-17 3   Afghanistan 1973    Sardar Mohammad Daoud   1973-07-17         3    2008    1978-04-30 4   Afghanistan 1978    Nur Mohammad Taraki     1978-04-30         3    2008    1979-12-27 

The result is supposed to be a Gantt Chart of all leaders in the world since 1945, when they were in charge and so on. Each country is one line. Each color is a type of regime (from democracy to dictatorship)

The documentation for Gantt Charts by plotly is not helping too much, especially for Python.

My current code looks like this:

df_dd_gantt_short = df.DataFrame  fig = ff.create_gantt(df_dd_gantt_short,                        colors=colors,                       index_col='Resource',                        show_colorbar=False,                        title='Regimes in history worldwide',                        showgrid_x=True,                       group_tasks=True)   plotly.offline.plot(fig, filename='regimes.html') 

I have a ton of questions, but the most important ones first:

  • Can I make round ends for each bar, so different leaders are clearly recognizable?

  • How can I create a legend on the bottom? In the current code I disabled the colorbar on the right as it is hidden on the bottom of a (never ending) scrolling frame.

  • As you can see on the image, the left side is weirdly cut off, is there a way to make that row wider?

  • How can I pick the whole bar as hover space instead of the ends and can I use my DataFrame as source for more info like here? I guess the whole loop thing is necessary for making all those changes above as well?

Thanks for your help!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!