Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Provide multiple output formats to IJulia #2195

Open
benz0li opened this issue Aug 3, 2022 · 8 comments
Open

Feature request: Provide multiple output formats to IJulia #2195

benz0li opened this issue Aug 3, 2022 · 8 comments
Labels
CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. Integration with other packages Makie Backend independent issues (Makie core) maybe outdated/fixed TODO: review

Comments

@benz0li
Copy link

benz0li commented Aug 3, 2022

Currently, only one output format is provided: png by default; otherwise what is set by the activate! 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 like Makie.js (CairoMakie) to return both image/svg+xml and application/pdf.

This allows IJulia to use

  • image/svg+xml for plot display in the browser
    + HTML conversion using SVG
  • application/pdf for direct PDF conversion

See JuliaPlots/Plots.jl#4288 about the same feature request for Plots.jl.

@benz0li
Copy link
Author

benz0li commented Aug 3, 2022

@jkrumbiegel
Copy link
Member

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.

@benz0li
Copy link
Author

benz0li commented Aug 10, 2022

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]:

  • png: 2m 32.1s (size: 1.1 MB)
  • svg: 14m 15s (size: 19.3 MB)
  • pdf: 2m 35s (size: 1.2 MB)

ℹ️ JupyterLab is able to display the svg while code-server fails miserably.

@benz0li
Copy link
Author

benz0li commented Aug 10, 2022

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.

@SimonDanisch
Copy link
Member

Feel free to open a PR with those changes! I don't think we currently have the resources to work on this!

@benz0li
Copy link
Author

benz0li commented Aug 10, 2022

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!

@asinghvi17 asinghvi17 added the Makie Backend independent issues (Makie core) label Feb 6, 2023
@ffreyer ffreyer added CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. maybe outdated/fixed TODO: review Integration with other packages labels Aug 23, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 23, 2024

Looks like you can set type in CairoMakie.activate!() now... Can this be closed?

@asinghvi17
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. Integration with other packages Makie Backend independent issues (Makie core) maybe outdated/fixed TODO: review
Projects
Status: No status
Development

No branches or pull requests

5 participants