Open benz0li opened 2 years ago
Cross references:
application/pdf
plot format in the notebook file, inkscape
is not required for PDF conversion using nbconvert
.
One problem is that for some plots with lots of data points, vector graphics become very large and slow. In those cases bitmaps are desirable, but even though CairoMakie uses png by default, it seems that IJulia still saves an svg for every plot and displays that because it is ranked higher.
One problem is that for some plots with lots of data points, vector graphics become very large and slow. In those cases bitmaps are desirable,
Agreed. Execution time (Intel® Xeon® Silver 4210R CPU @ 2.40GHz) for https://lazarusa.github.io/BeautifulMakie/withTheme/theme_dark_astronauts/ [all packages installed and precompiled]:
ℹ️ JupyterLab is able to display the svg while code-server fails miserably.
but even though CairoMakie uses png by default, it seems that IJulia still saves an svg for every plot and displays that because it is ranked higher.
I can't confirm that. You may login at https://demo.jupyter.b-data.ch with your GitHub account, Start image Julia (pubtools:latest) + code-server
and execute the following as a Jupyter notebook (.ipynb
)
Pkg.add("CairoMakie")
IJulia.ijulia_mime_types
import CairoMakie
x = range(0, 10, length = 100)
y = sin.(x)
CairoMakie.lines(x, y)
in JupyterLab or code-server; whatever you prefer.
If you then cat
the .ipynb
file in the Terminal, cells.outputs.data
of the last cell contains image/png
and text/plain
only.
ℹ️ IJulia does not do any image conversion on its own.
Feel free to open a PR with those changes! I don't think we currently have the resources to work on this!
The issue is now described in detail and the solution a nice to have. I currently do not have the resources to fix this either.
I will see if I can contribute something at a later date.
P.S.: Makie is great!
Looks like you can set type
in CairoMakie.activate!()
now... Can this be closed?
No, the question is asking for all possible formats to be marked showable/actually shown so Jupyter has access to png, svg and pdf output.
Currently, only one output format is provided:
png
by default; otherwise what is set by theactivate!
function (e.g.CairoMakie.activate!(type = "svg")
, but only if there is a match with https://github.com/JuliaLang/IJulia.jl/blob/1cdaf7e5e65c1221b4a3fac86f63253bea65a0c5/src/display.jl#L19-L28.Please provide every MIME type specified in the first level of that vector. 👉 After executing
IJulia.register_mime(MIME("application/pdf"))
I would likeMakie.js
(CairoMakie
) to return bothimage/svg+xml
andapplication/pdf
.This allows
IJulia
to useimage/svg+xml
for plot display in the browser + HTML conversion using SVGapplication/pdf
for direct PDF conversionSee https://github.com/JuliaPlots/Plots.jl/issues/4288 about the same feature request for
Plots.jl
.