Delphian
Delphian

Reputation: 1760

Draw heatmap using python

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?

Upvotes: 0

Views: 2683

Answers (1)

MCMZL
MCMZL

Reputation: 1146

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

Upvotes: 1

Related Questions