0
votes

I am trying to draw heatmap using Jupyter notebook. My table consists of 10 colomns and a lot of rows. The first row is the names of the colomns. I am using plotly lib.

import plotly.offline as py
import plotly.graph_objs as go
import pandas as pd
import numpy as np
import pickle
import matplotlib
import matplotlib.pyplot as plt
from pandas import ExcelWriter
from pandas import ExcelFile    

heatmap = go.Heatmap(
            z=dfs.corr(method='pearson').as_matrix(),
            x=dfs.columns,
            y=dfs.columns,
            colorbar=dict(title='Pearson Coefficient'),
        )

    layoutheat = go.Layout(title="title")

    figheat = go.Figure(data=[heatmap], layout=layoutheat)       
    py.iplot(figheat) 

dfs is dataframe.

Instead of graphic I get a lot of line like this:

'\ntrace = dict(\n x = x, y = y, z = z,\n type = "scatter3d", \n mode = \'markers\',\n marker = dict( size=5, color=\'black\', line=dict(width=0) ) )\ndata = [trace]\n \nlayout = dict(\n etc

What is the problem?

1
Please show your imports and a Dataframe for reproducibility - MCMZL
I added imports above. I can't show the dataframe but I take a simle dataframe from this link plot.ly/python/heatmaps and have the same result. - Delphian
Thanks, also it seems that you have an indent problem in your post. Your output is weird, it looks like the json of the figure is printed in the console, which usually happens when the kwarg asFigure=True - MCMZL
Thank you for your comment. I am not an expert in python. Can you explain what shall i do or where i can read about the kwarg ? - Delphian
Sorry it was related to cufflinks module a wrapper for python and pandas not related to your problem in fact. Are you running in Jupyter notebooks ? If so you need to add py.init_notebook_mode() after the import. If it still does not work I suggest to reinstall plotly - MCMZL

1 Answers

1
votes

If you are running a jupyter notebook you need to add py.init_notebook_mode() after the import. If it still does not work I suggest to reinstall plotly