I am trying to render charts using Plotly library in Databricks. However, no image is rendered. I use for example this statement:
from plotly.offline import init_notebook_mode, iplot
from plotly import graph_objs as go
# Initialize plotly
init_notebook_mode(connected=True)
daily_df=df
def plotly_df(df, title=''):
"""Visualize all the dataframe columns as line plots."""
common_kw = dict(x=df.index, mode='lines')
data = [go.Scatter(y=df[c], name=c, **common_kw) for c in df.columns]
layout = dict(title=title)
fig = dict(data=data, layout=layout)
iplot(fig, show_link=False)
plotly_df(daily_df)
There is no output. Why?
If you use plotly version 4.2, you no longer need to import plotly.offline and you can just call fig.show() on your figure created with Plotly Express or go.Figure(). The new renderer framework has a Databricks-specific renderer :)
Full documentation here: https://plot.ly/python/renderers/ and https://plot.ly/python/creating-and-updating-figures/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With