Commit
·
bf2b46a
1
Parent(s):
d21581b
v117
Browse files
app.py
CHANGED
|
@@ -224,7 +224,7 @@ def safe_get_column(df, column):
|
|
| 224 |
# If still not found, raise a helpful error
|
| 225 |
raise KeyError(f"Column '{column}' not found in DataFrame. Available columns: {list(df.columns)}")
|
| 226 |
|
| 227 |
-
def plot_and_save(plt, filename=None):
|
| 228 |
import os
|
| 229 |
if filename is None:
|
| 230 |
filename = PLOT_FILENAME
|
|
@@ -235,8 +235,12 @@ def plot_and_save(plt, filename=None):
|
|
| 235 |
# Ensure the directory exists
|
| 236 |
os.makedirs(os.path.dirname(filename) or '.', exist_ok=True)
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
# Save the plot
|
| 239 |
-
plt.savefig(filename,
|
| 240 |
plt.close()
|
| 241 |
print(f"[DEBUG] Plot saved to: {filename}")
|
| 242 |
return filename
|
|
|
|
| 224 |
# If still not found, raise a helpful error
|
| 225 |
raise KeyError(f"Column '{column}' not found in DataFrame. Available columns: {list(df.columns)}")
|
| 226 |
|
| 227 |
+
def plot_and_save(plt, filename=None, **savefig_kwargs):
|
| 228 |
import os
|
| 229 |
if filename is None:
|
| 230 |
filename = PLOT_FILENAME
|
|
|
|
| 235 |
# Ensure the directory exists
|
| 236 |
os.makedirs(os.path.dirname(filename) or '.', exist_ok=True)
|
| 237 |
|
| 238 |
+
# Set default savefig parameters if not provided
|
| 239 |
+
save_params = {'bbox_inches': 'tight', 'dpi': 100}
|
| 240 |
+
save_params.update(savefig_kwargs)
|
| 241 |
+
|
| 242 |
# Save the plot
|
| 243 |
+
plt.savefig(filename, **save_params)
|
| 244 |
plt.close()
|
| 245 |
print(f"[DEBUG] Plot saved to: {filename}")
|
| 246 |
return filename
|