Skip to content
Force display format to PNG

Force display format to PNG

February 28, 2026

In the VSCode plot panel and Literate.jl notebooks, PNG images are generally smaller than SVG ones. To force plots to be shown as PNG images, you can use DisplayAs.jl to show objects in a chosen MIME type.

import DisplayAs.PNG
using Plots
plot(rand(6)) |> PNG

If you don’t want to install another package, you could just use display().

using Plots
PNG(img) = display("image/png", img)
plot(rand(6)) |> PNG
Last updated on