海运热图显示为空

2ekbmq32  于 2022-09-21  发布在  其他
关注(0)|答案(1)|浏览(173)

我在用Python语言创建热图时遇到了麻烦。当我绘制热图时,它似乎是空的。然而,当我打开注解时,它在中间显示了非常小的数据。

有人知道该怎么做吗?


# 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

任何帮助都是非常感谢的!

m1m5dgzv

m1m5dgzv1#

您可以使用plotly.express来代替sns.heatmap执行以下操作:

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

相关问题