I have code as below that plots 6 scatterplots side by side.
import numpy as np
import pandas as pd
df_emb = pd.DataFrame(np.random.rand(1000,2))
df_emb['randNumCol'] = np.random.randint(0,6, size=len(df_emb))
df_emb.columns=['X','Y','label']
df_emb.head()
import matplotlib.pyplot as plt
import seaborn as sns
grid = sns.FacetGrid(df_emb, col = "label", hue = "label", col_wrap=3)
grid.map(sns.scatterplot, "X", "Y")
grid.add_legend()
plt.show()
1)
Is there any way to plot heatmaps instead of scatterplots? I tried grid.map(sns.heatmap, "X", "Y") but that doesnt work. I want to show specific areas on each map where there is higher density of observations
2)
if I have another list which has actual meaning of labels for example labels_meaning=['a','b','c','d','e','f'] then how could I display those labels instead of 0,1,2 etc
CodePudding user response:
I'd use a map to apply meaningful label names. Something like the following...
label_map = {0: 'Text 1', 1: 'Text 2', 2: 'Text 3', 3: 'Text 4', 4: 'Text 5', 5: 'Text 6'}
df_emb['label'] = df_emb['label'].map(label_map)
For the heatmap you could also try a kdeplot
grid.map(sns.kdeplot, "X", "Y", fill=True, common_grid=True)


