From 9b7000db4fe7fdc71c1a1c94d167c6afc65b8411 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Fri, 8 Dec 2023 21:46:32 +0530 Subject: [PATCH] curve fit img --- scripts/curve_fit.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/curve_fit.py diff --git a/scripts/curve_fit.py b/scripts/curve_fit.py new file mode 100644 index 0000000..e56fb95 --- /dev/null +++ b/scripts/curve_fit.py @@ -0,0 +1,31 @@ +import matplotlib.pyplot as plt +from matplotlib.backends.backend_svg import FigureCanvasSVG +import io + + +def create_svg_plot(): + # Create a sample plot + x = [1, 2, 3, 4, 5] + y = [2, 4, 6, 8, 10] + + fig, ax = plt.subplots() + ax.plot(x, y) + ax.set_title('Sample Plot') + ax.set_xlabel('X-axis') + ax.set_ylabel('Y-axis') + + # Convert the plot to SVG + svg_output = io.StringIO() + canvas = FigureCanvasSVG(fig) + canvas.print_svg(svg_output) + + # Close the plot to free up resources + plt.close(fig) + + # Return the SVG string + return svg_output.getvalue() + +# Example usage +svg_plot = create_svg_plot() +print(svg_plot) +