【问题标题】:I have been trying to display histogram on google colab but it is not showing我一直在尝试在 google colab 上显示直方图,但没有显示
【发布时间】:2022-08-02 23:14:47
【问题描述】:

我一直在尝试在 google colab 上显示直方图,但没有显示。
下面是不显示的代码 //imports from chart_studio import plotly from plotly.offline import init_notebook_mode, iplot init_notebook_mode(connected=True) import plotly.graph_objs as go

// code starts from here
trace = go.Histogram( 
x = data.defects,
opacity = 0.75,
name = \"Defects\",
marker = dict(color = \'green\'))

hist_data = [trace]
hist_layout = go.Layout(barmode=\'overlay\',
title = \'Defects\',
xaxis = dict(title = \'True - False\'),
yaxis = dict(title = \'Frequency\'),
)
fig = go.Figure(data = hist_data, layout = hist_layout)
iplot(fig) //This is not displaying anything

    标签: python google-colaboratory


    【解决方案1】:

    试试这个,在代码之前

    %matplotlib 内联

    将 matplotlib.pylab 导入为 plt

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-23
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多