Skip to content

Instantly share code, notes, and snippets.

@fonsp
Last active November 1, 2020 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fonsp/8ef96fd5d946b64b40576df43a829cb5 to your computer and use it in GitHub Desktop.
Save fonsp/8ef96fd5d946b64b40576df43a829cb5 to your computer and use it in GitHub Desktop.

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


img

David Sanders6 days ago

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

img

Jerry Ling6 days ago

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

img

Eric Hanson5 days ago

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)

img

Eric Hanson5 days ago

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)

:+1:1

Also sent to the channel

img

Fons van der Plas:pluto:4 days ago

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)

img

Sebastian Pfitzner4 days ago

I am :slightly_smiling_face:

img

Fons van der Plas:pluto:4 days ago

(you can also use PlutoUI.as``_png for very large plots to rasterize them)

img

Sebastian Pfitzner4 days ago

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?

img

Fons van der Plas:pluto:4 days ago

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

img

Fons van der Plas:pluto:4 days ago

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

img

Sebastian Pfitzner4 days ago

yeah that makes sense (edited)

img

Fons van der Plas:pluto:4 days ago

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

img

Sebastian Pfitzner4 days ago

fancy :wink:

img

Fons van der Plas:pluto:4 days ago

fonsp/Pluto.jl#577

img

Sebastian Pfitzner4 days ago

still won't help with really big svgs though

img

Sebastian Pfitzner4 days ago

but then again, nothing can

:+1:1

img

Sebastian Pfitzner4 days ago

except for refusing to render large blobs

Also sent to the channel

img

Matt Bichay4 days ago

I wonder if this was why Pluto was choking when I tried to make a large subplot with a scatter... hmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment