kovacsvi commited on
Commit
6db7031
·
1 Parent(s): 4ce3fc4

percentage sign x axis barplot

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -9,6 +9,7 @@ from transformers import AutoTokenizer
9
  import gradio as gr
10
  import matplotlib.pyplot as plt
11
  from matplotlib.colors import LinearSegmentedColormap
 
12
  import matplotlib.colors as mcolors
13
  import plotly.express as px
14
  import seaborn as sns
@@ -186,12 +187,14 @@ def plot_emotion_barplot(heatmap_data):
186
  fig, ax = plt.subplots(figsize=(8, 6))
187
  bars = sns.barplot(x=emotion_frequencies.values, y=emotion_frequencies.index, palette=palette, ax=ax)
188
 
 
 
189
  # Add % labels on the bars
190
  for i, (value, label) in enumerate(zip(emotion_frequencies.values, emotion_frequencies.index)):
191
  ax.text(value + 1, i, f"{int(value)}%", va='center')
192
 
193
  ax.set_title("Relative Frequencies of Predicted Emotions")
194
- ax.set_xlabel("Percentage")
195
  ax.set_ylabel("Emotions")
196
  plt.tight_layout()
197
 
 
9
  import gradio as gr
10
  import matplotlib.pyplot as plt
11
  from matplotlib.colors import LinearSegmentedColormap
12
+ from matplotlib.ticker import PercentFormatter
13
  import matplotlib.colors as mcolors
14
  import plotly.express as px
15
  import seaborn as sns
 
187
  fig, ax = plt.subplots(figsize=(8, 6))
188
  bars = sns.barplot(x=emotion_frequencies.values, y=emotion_frequencies.index, palette=palette, ax=ax)
189
 
190
+ ax.xaxis.set_major_formatter(PercentFormatter(xmax=100, decimals=0))
191
+
192
  # Add % labels on the bars
193
  for i, (value, label) in enumerate(zip(emotion_frequencies.values, emotion_frequencies.index)):
194
  ax.text(value + 1, i, f"{int(value)}%", va='center')
195
 
196
  ax.set_title("Relative Frequencies of Predicted Emotions")
197
+ ax.set_xlabel("Relative Frequency")
198
  ax.set_ylabel("Emotions")
199
  plt.tight_layout()
200