Skip to content Skip to sidebar Skip to footer

Seaborn Heatmap To Plotly Failed

I'm having plotly error when converting seaborn.heatmap figure to plotly. I'm doing that in jupyter notebook with following code: %matplotlib inline import numpy as np import seab

Solution 1:

According to this example, you would need to first convert your matplotlib figure to a Plotly object and then add the data manually. Whether that's more convenient than doing everything with Plotly from the beginning is a different issue.

enter image description here

%matplotlib inline

import plotly
import matplotlib as plt
import numpy as np
import seaborn as sns

plotly.offline.init_notebook_mode()

np.random.seed(2017)

data = np.random.randn(10, 20)
sns.heatmap(data)

mpl_fig = plt.pyplot.gcf()
plotly_fig = plotly.tools.mpl_to_plotly(mpl_fig)
plotly_fig['data'] = [dict(z=data, type="heatmap")]
plotly.offline.iplot(plotly_fig)

Post a Comment for "Seaborn Heatmap To Plotly Failed"