Jupyter笔记本中未显示密谋森伯斯特图 [英] Plotly sunburst plot not showing in Jupyter notebook

查看:118
本文介绍了Jupyter笔记本中未显示密谋森伯斯特图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Plotly和Jupyter生成一些视觉效果,以更好地了解在线用户的旅程.我正在使用Plotly森伯斯特图表,因为这样做可以使视觉效果很好. Plotly提供了一个很好的示例,并提供了我希望使用自己的数据产生的视觉效果.我创建了一个反映示例的数据框,但是当我尝试使用.show()时,未生成任何图表.它似乎运行良好(没有错误),并在图表应有但图表不产生空白的地方产生了空白.我们正在测试的数据最终最终大约为16,000行.

I am using Plotly and Jupyter to generate some visuals to better understand user journeys online. I am using the Plotly sunburst chart since this makes a great visual for that purpose. Plotly provides an example that works great and provides the visual that I am looking to produce with my own data. I have created a dataframe that mirrors the example but when I try to use .show() no chart is produced. It appears to run fine (no errors) and produces white space where the chart should be but not chart. The data we are testing on ends up being about about 16K rows ultimately.

我在Plotly的在线和离线游戏中都没有发挥作用.我尝试了不同的标签和ID.我还尝试过重新启动笔记本电脑,并且仅运行我的绘图,而不是先运行示例.我已经收集了我的数据,并缩小到了大约50行,其中有4个父节点,其余为后代.所有这些都得到了相同的结果,该图出现了空白,但没有生成图,也没有报告错误.

I have played around with the online vs offline for Plotly neither appeared to make a difference. I tried different labels and ID's. I have also tried restarting the notebook and only running my plot instead of the example first. I have taken my data and narrowed down to only about 50 lines with 4 parent nodes and the rest decedents. All of this got the same result of the white space appearing for the plot but no plot being produced and no errors reported.

import numpy as np                             
import pandas as pd
import plotly.graph_objects as go

df3=pd.read_csv('sessionsForAnalysis.csv')
df3['parents'] = df3.groupby(['sessionid'])['pagelabel'].shift(1)

df4=df3[['pagelabel','pagelabel','parents']]
df4.columns=["ids", "labels","parents"]
df4=df4.drop_duplicates()

fig1 = go.Figure()

fig1.add_trace(go.Sunburst(
    ids=df4.ids,
    labels=df4.labels,
    parents=df4.parents,
    #values=one_dimensional_array, #I added this
    domain=dict(column=0)
))



fig1.show()

我希望这会产生如下所示的朝阳图,类似于在此处除了我们的数据外,我们可以用它来分析旅程:

I expect this to produce a sunburst plot like below, similar to the one found here except with our data so we can use it to analyze journeys:

推荐答案

我没有特定的解决方案,但是至少在没有您自己的特定数据集的情况下,尽我所能提出了建议.

I don't have a specific solution, but at least a suggestion to the best of my abilities without your particular dataset.

我的第一个怀疑是您没有安装正确的软件包,但是因为您已经声明了

My first suspicion was that you did not have the correct packages installed, but since you've stated that

我都没有为Plotly玩过在线游戏还是离线游戏 似乎有所作为

I have played around with the online vs offline for Plotly neither appeared to make a difference

在我看来,您的问题 是您的数据,特别是 类型 或<数据的 结构 .来自您引荐的示例我尝试用values=['10', '14', '12', '10', '2', '6', '6', '4', '4']替换values=[10, 14, 12, 10, 2, 6, 6, 4, 4],但是效果很好,并增加了导致问题的是结构而不是类型的可能性.

it seems to me that your problem has to be your data, specifically the type or the structure of your data. From your referred example I tried replacing values=[10, 14, 12, 10, 2, 6, 6, 4, 4] with values=['10', '14', '12', '10', '2', '6', '6', '4', '4'], but that worked just fine and increases the probability that it's the structure and not type that causes the problems.

然后我弄乱了结构,将labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"]替换为 labels=["Eve", "Cain", "Noam", "Abel", "Awan", "Enoch", "Azura"].现在,不会生成任何图,并且不会显示以下错误消息:

Then I messed with the structure, replacing labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"] with labels=["Eve", "Cain", "Noam", "Abel", "Awan", "Enoch", "Azura"]. Now, no plot is produced with no error messages like this:

我的结论:确保parents中的每个观察结果都出现在labels中.

My conclusion: Make sure that each observation in parents occurs in labels.

labels移除'Noam'是可以的.似乎是因为'Noam'parents中没有出现:

Removing 'Noam' from labels is ok. seemingly because 'Noam' does not occur in parents:

从标签中删除'Seth'是不可行的:

Removing 'Seth' from labels is not ok:

因此,再次确保parents中的每个观察结果都出现在labels中,并查看是否对您有用.

So again, make sure that each observation in parents occurs in labels and see if that works out for you.

这篇关于Jupyter笔记本中未显示密谋森伯斯特图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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