我在用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
任何帮助都是非常感谢的!
1条答案
按热度按时间m1m5dgzv1#
您可以使用
plotly.express
来代替sns.heatmap
执行以下操作: