Seaborn Heatmap comes up empty

Viewed 40

I am having trouble with creating a heatmap in python. When I plot the heatmap it seams to come up empty. However, when I turn on annotations, it shows very small data in the middle.

Does anyone know what to do?

# Imports 

# Import pandas 
import pandas as pd

# Import NumPypip
import numpy as np

# From matplotlib import the PyPlot Module
from matplotlib import pyplot as plt

# From scikit-learn import the LinearRegression Module
from sklearn.linear_model import LinearRegression

# Import Seaborn
import seaborn as sns

# Use seaborn as a plotting style
plt.style.use('seaborn')

# Load the dataset into Python
df = pd.read_csv('assignment3-data-1.csv')

# Set x and y
x= df['phi']
y = df['psi']

hm_x = x 
hm_y = y 

data = pd.DataFrame(hm_x, hm_y)

fig2 = sns.heatmap(data)
plt.show(fig2)

This is what my data set looks like

      residue name  position chain         phi         psi
0              LYS        10     A -149.312855  142.657714
1              PRO        11     A  -44.283210  136.002076
2              LYS        12     A -119.972621 -168.705263
3              LEU        13     A -135.317212  137.143523
4              LEU        14     A -104.851467   95.928520
...            ...       ...   ...         ...         ...
29364          GLY       374     B -147.749557  155.223562
29365          GLN       375     B -117.428541  133.019506
29366          ILE       376     B -113.586448  112.091970
29367          ASN       377     B -100.668779  -12.102821
29368          LYS       378     B -169.951240   94.233680

[29369 rows x 5 columns]

plot of the heatmap, with the annotations

Any help is much appreciated!

1 Answers

Instead of sns.heatmap you can use plotly.express to do this:

import plotly.express as px
fig = px.density_heatmap(df, x="phi", y="psi")
fig.show()
Related