Spaces:
Sleeping
Sleeping
vickeee465
commited on
Commit
·
005b17a
1
Parent(s):
c5a271e
transpose heatmap
Browse files
app.py
CHANGED
|
@@ -89,15 +89,29 @@ def prepare_heatmap_data(data):
|
|
| 89 |
heatmap_data.columns = [item["sentence"][:18]+"..." for item in data]
|
| 90 |
return heatmap_data
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
plt.
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
plt.yticks(rotation=0)
|
| 99 |
-
plt.subplots_adjust(left=0.2, right=0.95, top=0.9, bottom=0.2)
|
| 100 |
plt.tight_layout()
|
|
|
|
| 101 |
return fig
|
| 102 |
|
| 103 |
def plot_sunburst_chart(heatmap_data):
|
|
|
|
| 89 |
heatmap_data.columns = [item["sentence"][:18]+"..." for item in data]
|
| 90 |
return heatmap_data
|
| 91 |
|
| 92 |
+
|
| 93 |
+
def plot_emotion_heatmap(heatmap_data, cmap="viridis"):
|
| 94 |
+
heatmap_data = heatmap_data.T
|
| 95 |
+
|
| 96 |
+
fig = plt.figure(figsize=(len(heatmap_data.columns) * 0.5 + 4, len(heatmap_data.index) * 0.5 + 2))
|
| 97 |
+
|
| 98 |
+
sns.heatmap(
|
| 99 |
+
heatmap_data,
|
| 100 |
+
annot=False,
|
| 101 |
+
cmap=cmap,
|
| 102 |
+
cbar=True,
|
| 103 |
+
linewidths=0.5,
|
| 104 |
+
linecolor='gray',
|
| 105 |
+
vmin=0,
|
| 106 |
+
vmax=1
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
plt.xlabel("Emotions")
|
| 110 |
+
plt.ylabel("Sentences")
|
| 111 |
+
plt.xticks(rotation=0, ha='right')
|
| 112 |
plt.yticks(rotation=0)
|
|
|
|
| 113 |
plt.tight_layout()
|
| 114 |
+
|
| 115 |
return fig
|
| 116 |
|
| 117 |
def plot_sunburst_chart(heatmap_data):
|