QuantEcon / lecture-julia.myst

Lecture source for "Quantitative Economics with Julia"
https://julia.quantecon.org/intro.html
54 stars 44 forks source link

PDF: Book PDF missing Plots #231

Closed mmcky closed 1 year ago

mmcky commented 1 year ago

The book PDF that was introduced yesterday is missing plots

mmcky commented 1 year ago

It looks like Julia Plots defaults to image/svg+xml mime types which will need to be converted to png for sphinx-jupyterbook-latex.

@AakashGfude we did something similar for the interactive figures right? Do we have a transform for converting images to a format latex can use. Hopefully it can be kernel agnostic by just treating mime types

I thought we converted svg but not sure about svg+xml

mmcky commented 1 year ago

@jlperla in the short term we could output png

https://docs.juliaplots.org/latest/output/

but I can't see a way to do this globally when loading Plots

mmcky commented 1 year ago
jlperla commented 1 year ago

Thanks. Yeah we can't change it to png globally. The notebooks can become massive (and everything is pretty ugly) if it goes raster instead of vector based.

mmcky commented 1 year ago

I have tested the other sphinx image converters to see if they worked in https://github.com/QuantEcon/lecture-julia.myst/pull/232 but this doesn't appear to solve our problem.

@jlperla neither of these options will be a quick fix on the software stack. The "best" solution to support pdf for now is to see if we can set the backend Plots to render to png files rather than svg+xml

mmcky commented 1 year ago

Thanks. Yeah we can't change it to png globally. The notebooks can become massive (and everything is pretty ugly) if it goes raster instead of vector based.

ah just saw this -- this is true. I am wondering if we can set to png just for the pdf builds. 🤔

jlperla commented 1 year ago

One thing to try is that you could add in a default(fmt = :png) after the initial using Plots or using StatsPlots?

If you have preprocessing before the pdf build you could just find all instances of using and Plots in the same block (to consider the using LinearAlgebra, AnotherPackages, Plots, EvenMorePackages
And then add in the default(fmt = :png)?

Not positive this fixes the problem, though.

Keep in mind, though, that the PDF may end up enormous unless you also do some sort of compression with the pngs as a substep itself. There are a lot of figures in the paper and many of them are the sorts of simulations/ensembles that make especially large png files.