leonsimon23 commited on
Commit
d86885c
·
verified ·
1 Parent(s): 41a3aaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -144,11 +144,22 @@ def run_full_analysis(progress=gr.Progress(track_tqdm=True)):
144
 
145
  stl = STL(ts_data, period=period, seasonal=seasonal_period_for_stl)
146
  res = stl.fit()
147
- fig, axes = plt.subplots(4, 1, figsize=(12, 8), sharex=True)
 
148
  # 使用 res.plot() 可以自动处理标签
149
- res.plot(axes=axes)
150
- fig.suptitle(f'STL 分解图 (周期={period})', fontsize=16)
151
- plt.tight_layout(rect=[0, 0, 1, 0.96])
 
 
 
 
 
 
 
 
 
 
152
  figures.append(fig)
153
  log_lines.append("✅ STL分解图已生成。")
154
  else:
 
144
 
145
  stl = STL(ts_data, period=period, seasonal=seasonal_period_for_stl)
146
  res = stl.fit()
147
+
148
+ #fig, axes = plt.subplots(4, 1, figsize=(12, 8), sharex=True)
149
  # 使用 res.plot() 可以自动处理标签
150
+ #res.plot(axes=axes)
151
+ #fig.suptitle(f'STL 分解图 (周期={period})', fontsize=16)
152
+ #plt.tight_layout(rect=[0, 0, 1, 0.96])
153
+
154
+
155
+ # 【关键修复】直接调用 res.plot(),它会返回一个 Figure 对象
156
+ fig = res.plot()
157
+
158
+ # 调整 Figure 的大小和标题
159
+ fig.set_size_inches(12, 8)
160
+ fig.suptitle(f'STL 分解图 (周期={period})', fontsize=16, y=0.98) # 使用 y 参数调整标题位置
161
+ plt.tight_layout() # 自动调整布局
162
+
163
  figures.append(fig)
164
  log_lines.append("✅ STL分解图已生成。")
165
  else: