chore: Perform codebase cleanup and refactor App state management
This commit is contained in:
17
backend/src/ea_chatbot/utils/plots.py
Normal file
17
backend/src/ea_chatbot/utils/plots.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import io
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def fig_to_bytes(fig: plt.Figure, format: str = "png") -> bytes:
|
||||
"""
|
||||
Convert a Matplotlib figure to bytes.
|
||||
|
||||
Args:
|
||||
fig: The Matplotlib figure to convert.
|
||||
format: The image format to use (default: "png").
|
||||
|
||||
Returns:
|
||||
bytes: The image data.
|
||||
"""
|
||||
buf = io.BytesIO()
|
||||
fig.savefig(buf, format=format)
|
||||
return buf.getvalue()
|
||||
Reference in New Issue
Block a user