My 16KB notebooks end up 16MB if I keep the output of Plots in them. Is there an IJulia friendly way to use Plots that will not increase the notebook size as much?
If it is due to large SVGs you can display them in
png format instead with
You can also store your notebook in text only format using https://github.com/fredrikekre/Literate.jl, and just call the plot commands from there (like https://github.com/fredrikekre/Literate.jl/blob/22c6d530d3d331cd0b260c745bd1d48274c56dfd/examples/example.jl#L66-L70). The notebooks are then “render targets” (so they are not checked into your main branch of the repo). They could be rendered as part of documentation deployment for example.
display("image/png", plot). (Would be nice if there were a way to make this the default in Plots.jl, since SVGs can get large and slow to render very easily.)
Meant to write
MIME("image/png") but your way is of course shorter.
using Plots default(fmt = :png)
This is perhaps related:
The new IJulia 1.11.1 works nicely on Julia 1.0.0 (thanks!), but it seems as if the new notebooks with plots (using Plots) often do not render on GitHub, at least if they include several plots, and some markdown cells.
One can even use
Literate twice, to create a Markdown for the docs and a non executed clean notebook in the main repo for users to follow along
nbstripout maybe? (If storage is the concern)
Here is a strange observation:
The following cell immediately increases the notebook size to 16MB
using Plots gr(size=(600,400)) default(fmt = :png)
and then the size stays flat (even after adding plenty of more cells).
However, if I instead run that same cell twice, then the size decreases to 15Kb or so.
UInt8 vector is 16MB.
Opened a Plots issue: https://github.com/JuliaPlots/Plots.jl/issues/1724
Thanks for looking into this. Is there currently any other way (than “run twice”) to get around this?
Doesn’t look like it.
I have the same problem (Jupyter notebooks that are very large and slow, probably due to plots). I have ran
display(MIME("image/png")), but the size of the notebook is the same (15MB).
Is there another solution to this?
The notebook is too slow and gets jammed all the time.
I figured out that I can plot a
plot(x, y, fmt = :png). The notebook still takes a lot of disk space (~8MB), but it responds much faster.
What is inside the notebook (as in you open it with a text editor and look)? I remember https://github.com/JuliaPlots/Plots.jl/issues/1724 but that should be fixed by now I think.
@kristoffer.carlsson sorry for my ignorance, but I am a new user. I am not sure what to look for in the notebook file.
In the link you added, I see they are using
Plotly but I am not.
I can confirm that the 16MB blowup does not happen with latest version. I tried GR, Plotly and PlotlyJS backends.
P.S. I am not sure if PlotlyJS is completely functional, it does not seem to respond to hovering mouse pointer by showing the closest value as it used to. I also get a missing dependency (ORCA), which I have to manually install before using PlotlyJS.