绘图对象在 DataBricks 中显示为空白

dat*_*tam 5 python plotly databricks

我有一个应该正确显示的绘图对象,但由于某种原因,它在 DataBricks 中只显示为空白。对象类型为:

plotly.graph_objs._figure.Figure
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法来显示该图:

fig.show()
display(fig)
displayHTML(fig.to_html())
Run Code Online (Sandbox Code Playgroud)

我能想到的所有可能的解决方案都会导致同样的事情。谢谢!顺便说一句...使用 Plotly 4.9 版

Der*_*k O 3

尝试使用plot中的方法plotly.offline。以下内容来自DataBricks 文档,但 Jupyter 笔记本也有类似的问题,除非您使用plotly.offline.

from plotly.offline import plot
import plotly.graph_objects as go

# Instead of simply calling plot(...), store your plot as a variable and pass it to displayHTML().
# Make sure to specify output_type='div' as a keyword argument.
# (Note that if you call displayHTML() multiple times in the same cell, only the last will take effect.)

p = plot(
  [ ## define your go.Figure here ##

  ],
  output_type='div'
)

displayHTML(p)
Run Code Online (Sandbox Code Playgroud)