Helper function to convert matplotlib figure to SVG string

    Returns:
        str: figure as SVG string

def fig_to_svg(fig):
    """Helper function to convert matplotlib figure to SVG string

    Returns:
        str: figure as SVG string
    """
    buf = io.StringIO()
    fig.savefig(buf, format='svg')
    buf.seek(0)
    return buf.getvalue()