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

support for pdf plot output #1035

Closed
jjallaire opened this issue Mar 17, 2022 · 7 comments · Fixed by JuliaPlots/Plots.jl#4188
Closed

support for pdf plot output #1035

jjallaire opened this issue Mar 17, 2022 · 7 comments · Fixed by JuliaPlots/Plots.jl#4188

Comments

@jjallaire
Copy link

Hi there, we've been putting some work into integrating support for IJulia into Quarto (https://quarto.org), which is a scientific publishing system based on Pandoc (sort of like R Markdown, in fact built by the same team, but fundamentally cross-language and cross-engine).

We have plots working correctly w/ various output formats, but one noteworthy limitation is that when creating a PDF the plot output is provided as PNG (as SVG currently doesn't work out of the box w/ LaTeX). As you can imagine this results in dramatically lower quality than is possible with native PDF plot output. One of Quarto's main uses cases is creation of scientific publications for academic journals, so getting high quality output ends up being pretty important.

I see the available output formats in IJulia enumerated here:

IJulia.jl/src/display.jl

Lines 19 to 28 in cc2a9bf

const ijulia_mime_types = Vector{Union{MIME, AbstractVector{MIME}}}([
MIME("text/plain"),
MIME("image/svg+xml"),
[MIME("image/png"),MIME("image/jpeg")],
[
MIME("text/markdown"),
MIME("text/html"),
],
MIME("text/latex"),
])

Further, I noted the place where JuliaPlots is yielding output here:

https://github.com/JuliaPlots/Plots.jl/blob/master/src/ijulia.jl#L33-L56

It would be fantastic if these could be updated to produce PDF output. This might not at first blush seem to make sense for a "notebook" but if you think of Jupyter as an execution engine for realizing executable code into output it makes more sense (i.e. think about nbconvert as the client rather than the traditional browser front end). This does in fact currently work for Matplotlib output on the Python side.

It's certainly a fine stopgap to use PNG output for plots in PDFs, but my guess is that when users start creating articles they want to submit for publication that the PDF support will quickly go from nice-to-have to must have.

@jeremiahpslewis
Copy link

Ok, so based on the above linked PRs, the suggested changes in this issue work to fix it, example here: https://jeremiahpslewis.github.io/quarto-reproducible-gh-actions/quarto-and-github-actions.pdf

Codebase: https://github.com/jeremiahpslewis/quarto-reproducible-gh-actions

@jeremiahpslewis
Copy link

Screen Shot 2022-04-29 at 15 54 27

@jjallaire
Copy link
Author

Once this lands we still might need to change Quarto to stop "redirecting" pdf to png here: https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/jupyter/lang/julia/setup.jl#L22-L27

Further, we might want some sort of version check to make sure that we use the workaround when updated IJulia isn't avaialble.

@jeremiahpslewis
Copy link

Ooh, good that you mention a workaround for earlier versions of IJulia (once/if PR is merged). I wanted to suggest a slightly different approach: what about a Quarto.jl package which bundles the logic which is currently in the setup.jl file, requires a couple of packages (Plots, IJulia), and sets a lower bound on the packages based on PDF support (and other things as they may come up in the future).

@jjallaire
Copy link
Author

I think we need to keep the code in setup.jl in sync with the current version of Quarto (there can be dependencies both ways) so it's much better to have this be embedded (otherwise the package will need to have quarto version conditional code and quarto will need to have package version conditional code)

@jeremiahpslewis
Copy link

I think this can be closed, see discussion here: #1038

@jeremiahpslewis
Copy link

This PR to quarto will (when ready) resolve this issue quarto-dev/quarto-cli#800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants