def svg2str(display_object, dpi=300):
    """
    Serializes a nilearn display object as a string
    """
    from io import StringIO
    image_buf = StringIO()
    display_object.frame_axes.figure.savefig(image_buf, dpi=dpi, format=
        'svg', facecolor='k', edgecolor='k')
    return image_buf.getvalue()
