IJulia: Save a Image from PyPlot as PDF in JupyterLab


I use jupyter-lab with IJulia kernel for my research. I use PyPlot for my plotting.
When using normal Julia scripts, I’m able to use

# ... Code to  Plot data...
savefig( "my_results.pdf", bbox_inches = "tight", pad_inches = 0.1 )

to save the figure as PDF format.

But if I try to execute the same code from JupyterLab with IJulia, I get blank PDF file. Right now the work around is to save the Image but right clicking and saving it as default PNG image. But this creates problems when I zoom into the saved figure. Hence I want to get PDF figure. (SVG is also an option, but if I want to put the image to latex, SVG is not supported AFAIK.)

How can I export a image I plotted in my notebook using PyPlot as a PDF figure?

With Regards,

I don’t know the complete answer, but if you execute savefig in the same notebook cell as all the other plot commands, it works.