Get help from the marimo community

Home
Members
HexxCube
H
HexxCube
Offline, last seen 2 months ago
Joined November 25, 2024
The inline matplotlib plots are shown as png and look blurry on my 4k monitor. Increasing the plots dpi only scales it up. Is it possible to display them as a svg instead?

I already tried locally changing:
marimo/_output/mpl.py
Plain Text
def _internal_show(canvas: FigureCanvasBase) -> None:
    buf = io.BytesIO()
    buf.seek(0)
    canvas.figure.savefig(buf, format="png", bbox_inches="tight")
    plt.close(canvas.figure)
    mimetype: KnownMimeType = "image/png"
    plot_bytes = base64.b64encode(buf.getvalue())
    CellOp.broadcast_console_output(
        channel=CellChannel.MEDIA,
        mimetype=mimetype,
        data=build_data_url(mimetype=mimetype, data=plot_bytes),
        cell_id=None,
        status=None,
    )

to
Plain Text
def _internal_show(canvas: FigureCanvasBase) -> None:
    buf = io.BytesIO()
    buf.seek(0)
    canvas.figure.savefig(buf, format="svg", bbox_inches="tight")
    plt.close(canvas.figure)
    mimetype: KnownMimeType = "image/svg+xml"
    plot_bytes = base64.b64encode(buf.getvalue())
    CellOp.broadcast_console_output(
        channel=CellChannel.MEDIA,
        mimetype=mimetype,
        data=build_data_url(mimetype=mimetype, data=plot_bytes),
        cell_id=None,
        status=None,
    )

but it still shows up as a png.
2 comments
H
M