danielritchie commited on
Commit
b8282c8
·
verified ·
1 Parent(s): fb07755

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -2
app.py CHANGED
@@ -105,8 +105,36 @@ def generate_scatter(raw, amplified, cinematic, label, passion, drama):
105
  alpha=0.9
106
  )
107
 
108
- ax.set_xlim(0, 1)
109
- ax.set_ylim(0, 1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  ax.set_xlabel("Valence")
111
  ax.set_ylabel("Arousal")
112
  ax.set_title(f"{label}\nPassion={round(passion,2)} | Drama={round(drama,2)}")
 
105
  alpha=0.9
106
  )
107
 
108
+ # ----------------------------------
109
+ # Dynamic Zoom (Centered + 20% Padding)
110
+ # ----------------------------------
111
+ xs = [raw["V"], amplified["V"], cinematic["V"]]
112
+ ys = [raw["A"], amplified["A"], cinematic["A"]]
113
+
114
+ min_x, max_x = min(xs), max(xs)
115
+ min_y, max_y = min(ys), max(ys)
116
+
117
+ span_x = max_x - min_x
118
+ span_y = max_y - min_y
119
+
120
+ # Use the larger span to keep square framing
121
+ span = max(span_x, span_y)
122
+
123
+ # Avoid zero-span collapse
124
+ span = max(span, 0.05)
125
+
126
+ padding = span * 0.20 # 20% larger
127
+
128
+ center_x = (min_x + max_x) / 2
129
+ center_y = (min_y + max_y) / 2
130
+
131
+ half_range = (span / 2) + padding
132
+
133
+ ax.set_xlim(center_x - half_range, center_x + half_range)
134
+ ax.set_ylim(center_y - half_range, center_y + half_range)
135
+
136
+ ax.set_aspect('equal', adjustable='box')
137
+
138
  ax.set_xlabel("Valence")
139
  ax.set_ylabel("Arousal")
140
  ax.set_title(f"{label}\nPassion={round(passion,2)} | Drama={round(drama,2)}")