Fixed line color issue (ensured valid HEX format)
Browse files5 unmodified lines6789101112131415164 unmodified lines212223242526275 unmodified linesdef plot_function(func_str, x_min, x_max, resolution, color, linestyle, grid):try:# Ensure a valid color (default to black if None or invalid)if not color or not color.startswith("#") or len(color) != 7:color = "#000000" # Default to blackrgba_color = mcolors.to_rgba(color) # Convert HEX to RGBAx_values = np.linspace(x_min, x_max, resolution)functions = func_str.split(",")4 unmodified linesfunc_text = func_text.strip()func = lambda x: eval(func_text, {"x": x, "np": np})y_values = func(x_values)plt.plot(x_values, y_values, label=f"f(x) = {func_text}", color=rgba_color, linestyle=linestyle)plt.xlabel("x")plt.ylabel("f(x)")5 unmodified lines678910111213141516174 unmodified lines222324252627285 unmodified linesdef plot_function(func_str, x_min, x_max, resolution, color, linestyle, grid):try:# Ensure the color is always a valid HEX stringif not color or not color.startswith("#") or len(color) != 7:color = "#000000" # Default to black# Convert to proper HEX format for Matplotlibcolor = mcolors.to_hex(color)x_values = np.linspace(x_min, x_max, resolution)functions = func_str.split(",")4 unmodified linesfunc_text = func_text.strip()func = lambda x: eval(func_text, {"x": x, "np": np})y_values = func(x_values)plt.plot(x_values, y_values, label=f"f(x) = {func_text}", color=color, linestyle=linestyle)plt.xlabel("x")plt.ylabel("f(x)")
app.py+4-3