chore: Perform codebase cleanup and refactor App state management

This commit is contained in:
Yunxiao Xu
2026-02-17 02:34:47 -08:00
parent ec6760b5a7
commit a94cbc7f6d
9 changed files with 90 additions and 46 deletions

View 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()