《朱庇特笔记本》中正在消失的普洛特利情节? [英] Disappearing Plotly plots in Jupyter Notebook?
本文介绍了《朱庇特笔记本》中正在消失的普洛特利情节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,当我打开Jupyter Notebook时,我必须重新加载数据集才能在Jupyter Notebook中再次显示它:
#Size of the plot
figsize=(10,5)
#Count of values of good and bad credits in the dataset
goodCount = data[data["Risk"]== 'good']["Risk"].value_counts().values
badCount = data[data["Risk"]== 'bad']["Risk"].value_counts().values
#Bar fo good credit
trace0 = go.Bar(x = data[data["Risk"]== 'good']["Risk"].value_counts().index.values,
y = data[data["Risk"]== 'good']["Risk"].value_counts().values,
name='Good credit',
text= goodCount,
textposition="auto",
marker = dict(color = "green", line=dict(color="black", width=1),),opacity=1)
#Bar of bad credit
trace1 = go.Bar(x = data[data["Risk"]== 'bad']["Risk"].value_counts().index.values,
y = data[data["Risk"]== 'bad']["Risk"].value_counts().values,
name='Bad credit',
text= badCount,
textposition="auto",
marker = dict(color = "red", line=dict(color="black", width=1),),opacity=1)
#Creation of bar plot
data = [trace0, trace1]
layout = go.Layout()
layout = go.Layout(yaxis=dict(title='Count'),
xaxis=dict(title='Risk variable'),
title='Distribution of target variable in the dataset')
fig = go.Figure(data=data, layout=layout)
fig.show()
推荐答案
troubleshooting guide建议运行"重新启动并清除输出"菜单命令,或在任何单元格中随时执行此块,以便在情况不同步时恢复图形:
import plotly.io as pio
pio.renderers.default='notebook'
您看到的是Ploly Notebook集成的一个限制,如果您可以升级到它,在JupyterLab中会更好:)
这篇关于《朱庇特笔记本》中正在消失的普洛特利情节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文