xoarissa commited on
Commit
33f9631
·
1 Parent(s): 26e5cc9

Fixed plot not loading issue (ensured correct file save path)

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -29,11 +29,17 @@ def plot_function(func_str, x_min, x_max, resolution, color, linestyle, grid):
29
  if grid:
30
  plt.grid()
31
 
32
- plot_filename = os.path.abspath("high_res_plot.png")
33
- plt.savefig(plot_filename, dpi=300)
 
 
34
  plt.close()
35
 
36
- return plot_filename, plot_filename
 
 
 
 
37
 
38
  except Exception as e:
39
  return f"Error: {e}", None
 
29
  if grid:
30
  plt.grid()
31
 
32
+ # Save the plot correctly and return an absolute path
33
+ plot_filename = "high_res_plot.png"
34
+ abs_path = os.path.abspath(plot_filename) # Convert to absolute path
35
+ plt.savefig(abs_path, dpi=300)
36
  plt.close()
37
 
38
+ # Ensure the file exists before returning
39
+ if os.path.exists(abs_path):
40
+ return abs_path, abs_path
41
+ else:
42
+ return "Error: Plot file was not created", None
43
 
44
  except Exception as e:
45
  return f"Error: {e}", None