Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotly Object displays as blank in DataBricks

I have a plotly object that should be showing up properly but for some reason it only shows up blank in DataBricks. The object type is:

plotly.graph_objs._figure.Figure

I have tried the following to display the figure:

fig.show()
display(fig)
displayHTML(fig.to_html())

All possible solutions I can think of result in the same thing. Thanks! Btw... Using Plotly Version 4.9

like image 538
datam Avatar asked Nov 06 '22 05:11

datam


1 Answers

Try using the plot method from plotly.offline. This following is from DataBricks documentation, but Jupyter notebooks have a similar issue where a Plotly graph_object Figure won't render unless you use 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)
like image 134
Derek O Avatar answered Nov 15 '22 09:11

Derek O