https://julialang.slack.com/archives/C017Z6Q3WS3/p1603760887270300
looks like pluto would become extremely slow if there's a big svg plot? e.g
using Plots
scatter(rand(10^5), rand(10^5))
18 replies
I don't think any environment would handle that gracefully. Eg jupyter would be slow too. You could just make a 2d histogram instead, or move to makie
in the end I want the 2d histogram, but that was for debugging purpose, I either lower it to 10^3 or fmt=:png
, but yeah, it felt even slower than jupyter
CairoMakie outputs SVGs by default and I ran into the same problem (so I used CarioMakie.activate!(type="png")
to switch to PNGs by default). Probably WGLMakie would handle it better? Not totally sure since I couldn't get it working (my pluto notebook is served remotely and I think there's some port issues with WGLMakie)
I wonder if there's a way that Pluto could just refuse to render the SVG if it's too big? rather than the whole browser slowing down, making it hard to fix the issue (edited)
Also sent to the channel
It's faster if you force Plots.jl to output svg instead of svg-inside-HTML:
let
hackahcakhcak
scatter(...)
end |> PlutoUI.as_svg
(since PlutoUI 0.6.8 from last week)we can talk more about why this is faster if anyone is interested? (edited)
(you can also use PlutoUI.as``_png
for very large plots to rasterize them)
Does as_svg
do data stripping or something like that? Or is it just a matter of rendering the svg in an img
tag instead of in the dom?
I haven't figured it out completely but if an image is rendered as SVG MIME, then Pluto renders it as <img src=".. the svg data ..">
instead of .innerHTML
so this must cause the performance increase
as for why, I think it is because CSS is only applied to the latter, so the browser can skip the CSS calculations in the former
yeah that makes sense (edited)
a second Pluto-specific thing is that when a cell updates, and the output before and after are both <img
, then it will only replace the src
, which prevents a one-frame flicker
still won't help with really big svgs though
but then again, nothing can
except for refusing to render large blobs
Also sent to the channel
I wonder if this was why Pluto was choking when I tried to make a large subplot with a scatter... hmm