I'm not able to use Gadfly + Weave

I have a very simple .jmd file

using Gadfly
x = range(0, step=0.1, stop=2*pi)
Gadfly.plot(x = x, y = sin.(x))

(I had to escape the backticks when composing this message). When calling weave on the .jmd file, I get an error (see below). If I replace “Gadfly” with “Plots”, it works. If I run the code snippet in REPL, it works with both Plots and Gadfly. So why does it fail when using Gadfly in Weave?

Julia code invoking weave:
weave("path/to/file.jmd", out_path=save_path, doctype = "md2html", mod=mymodule)


┌ Info: Weaving chunk 1 from line 8
└   progress = 0.0
┌ Info: Weaving chunk 2 from line 16
└   progress = 0.5
┌ Warning: ERROR: ErrorException occurred, including output in Weaved document
└ @ Weave C:\path\.julia\packages\Weave\lf3HS\src\run.jl:234
┌ Info: Weaved all chunks
└   progress = 1
ERROR: LoadError: SystemError: opening file "D:\\mypath\\reports\\20201005__20_56_56_605\\jl_ngvppF/report_2_1.png": No such file or directory
 [1] systemerror(::String, ::Int32; extrainfo::Nothing) at .\error.jl:168
 [2] #systemerror#48 at .\error.jl:167 [inlined]
 [3] systemerror at .\error.jl:167 [inlined]
 [4] open(::String; lock::Bool, read::Bool, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing) at .\iostream.jl:284
 [5] open(::String, ::String; lock::Bool) at .\iostream.jl:346
 [6] open at .\iostream.jl:346 [inlined]
 [7] img2base64(::String, ::String) at C:\path\.julia\packages\Weave\lf3HS\src\run.jl:152
 [8] embed_figures!(::Weave.CodeChunk, ::String) at C:\path\.julia\packages\Weave\lf3HS\src\run.jl:140
 [9] embed_figures! at C:\path\.julia\packages\Weave\lf3HS\src\run.jl:146 [inlined]
 [10] run_chunk(::Weave.CodeChunk, ::Weave.WeaveDoc, ::Weave.Report, ::Module) at C:\path\.julia\packages\Weave\lf3HS\src\run.jl:134
 [11] run_doc(::Weave.WeaveDoc; doctype::String, out_path::String, args::Dict{Any,Any}, mod::Module, fig_path::Nothing, fig_ext::Nothing, cache_path::String, cache::Symbol) at C:\path\.julia\packages\Weave\lf3HS\src\run.jl:74
 [12] weave(::String; doctype::String, informat::Nothing, out_path::String, args::Dict{Any,Any}, mod::Module, fig_path::Nothing, fig_ext::Nothing, cache_path::String, cache::Symbol, template::Nothing, css::Nothing, highlight_theme::Nothing, pandoc_options::Array{String,1}, latex_cmd::Array{String,1}, keep_unicode::Bool) at C:\path\.julia\packages\Weave\lf3HS\src\Weave.jl:177
 [20] top-level scope at .\REPL[4]:0
in expression starting at D:\mypath\myfile.jl:38

what is weave?


1 Like

Also having issue with Weave+Gadfly. BTW, I’m doing md2pdf as output format. Searched Internet and found below. Are they related?


For unknown reason, the file “D:\mypath\reports\20201005__20_56_56_605\jl_ngvppF/report_2_1.png” (yours) is non-existent - that is what happened in my case.

Seems a PR has been filed -> https://github.com/JunoLab/Weave.jl/issues/403

Weave is attempting to load a PNG. I think you need to add using Cairo, Fontconfig for the presumed PNG to generate.

Yes, this works! My working code is below.

using Gadfly
using Cairo
using Fontconfig
#x = linspace(0, 2*pi)
x = range(0,stop=2*pi,length=10)
plot(x = x, y = sin.(x))
1 Like