Skip to content Skip to sidebar Skip to footer

Typeerror When Plotting Heatmap With Seaborn

I have the following dataset in a pandas DataFrame, which I've tidied and saved into 'filename1.csv': import pandas as pd df = pd.read_csv('filename1.csv') print(df) samples

Solution 1:

If you just drop the "samples" column as well, isn't that what you are looking for?! You can then put the sample names in later using matplotlib's ax.set_yticklabels function. Note that you need to reverse sample names list, since matplotlib starts the labeling from the bottom.

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

df = pd.read_csv("SO_pandassnsheatmap.txt", delim_whitespace=True)
df2 = df.drop(["samples", "a", "b", "c", "ratio_a:b", "ratio_c:b"], axis = 1)
ax = sns.heatmap(df2)
ax.set_yticklabels(df.samples.values[::-1])

plt.show()

enter image description here

Post a Comment for "Typeerror When Plotting Heatmap With Seaborn"