用Python绘制-甘特图的极限 [英] plotly with Python - limits of Gantt Chart

查看:829
本文介绍了用Python绘制-甘特图的极限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的数据框,它是一个应用程序日志:

I have a dataframe like this which is an application log:

+---------+----------------+----------------+---------+----------+-------------------+------------+
|  User   | ReportingSubId | RecordLockTime | EndTime | Duration | DurationConverted | ActionType |
+---------+----------------+----------------+---------+----------+-------------------+------------+
| User 5  |             21 | 06:19.6        | 06:50.5 |       31 | 00:00:31          | Edit       |
| User 4  |             19 | 59:08.6        | 59:27.6 |       19 | 00:00:19          | Add        |
| User 25 |             22 | 29:09.4        | 29:37.0 |       28 | 00:00:28          | Edit       |
| User 10 |             19 | 28:36.9        | 33:37.0 |      300 | 00:05:00          | Add        |
| User 27 |             22 | 13:27.7        | 16:54.9 |      207 | 00:03:27          | Edit       |
| User 5  |             21 | 11:22.8        | 12:37.3 |       75 | 00:01:15          | Edit       |
+---------+----------------+----------------+---------+----------+-------------------+------------+

我想可视化每个用户的添加和编辑时间,广告Gantt Chart对我来说似乎很理想.

I wanted to visualize the duration of adds and edits for each user, ad Gantt Chart seemed ideal for me.

我能够使用以下代码对807行的示例数据帧执行此操作:

I was able to do it for a sample dataframe of 807 rows with the following code:

data = []

for row in df_temp.itertuples():
    data.append(dict(Task=str(row.User), Start=str(row.RecordLockTime), Finish=str(row.EndTime), Resource=str(row.ActionType)))

colors = {'Add': 'rgb(110, 244, 65)',
          'Edit': 'rgb(244, 75, 66)'}

fig = ff.create_gantt(data, colors=colors, index_col='Resource', show_colorbar=True, group_tasks=True)

for i in range(len(fig["data"]) - 2):
    text = "User: {}<br>Start: {}<br>Finish: {}<br>Duration: {}<br>Number of Adds: {}<br>Number of Edits: {}".format(df_temp["User"].loc[i], 
                                                                                                                                 df_temp["RecordLockTime"].loc[i], 
                                                                                                                                 df_temp["EndTime"].loc[i], 
                                                                                                                                 df_temp["DurationConverted"].loc[i], 

                                                                                                                                 counts[counts["User"] == df_temp["User"].loc[i]]["Add"].iloc[0],
                                                                                                                                 counts[counts["User"] == df_temp["User"].loc[i]]["Edit"].iloc[0])
    fig["data"][i].update(text=text, hoverinfo="text")

fig['layout'].update(autosize=True, margin=dict(l=150))
py.iplot(fig, filename='gantt-group-tasks-together', world_readable=True)

我对结果感到非常满意: https://plot.ly/~pawelty /90.embed

and I am more than happy with the result : https://plot.ly/~pawelty/90.embed

但是我最初的df有更多的用户,总共有2500行.阴谋似乎太过分了.我收到502错误.

However my original df has more users and 2500 rows in total. That seems to be too much for plotly. I get 502 error.

我是密谋的忠实拥护者,但我可能已经达到极限了.我可以更改某些内容以便使用Plotly对其进行可视化吗?我可以使用其他工具吗?

I am a huge fan of plotly but I might have reached it's limit. Can I change something in order to visualize it with Plotly ? Any other tool I could use?

推荐答案

我开始使用plotly.offline.plot(fig)进行离线绘制,它的工作速度更快,并且出错的次数也更少.我也有一个问题,我的图形无法显示,或者有时只能在全屏模式下显示.

I started using plotly.offline.plot(fig) to plot offline and it worked much faster and I got less errors. I also have the problem that my graph doesn't get displayed or sometimes only in fullscreen mode...

虽然我导入的是plotly而不是plotly.plotly,否则它不起作用.

I import plotly instead of plotly.plotly though, otherwise it doesn't work.

这篇关于用Python绘制-甘特图的极限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆