mirror of https://github.com/mpastell/Weave.jl
Fix Plots support
parent
93bb9ced2d
commit
973274bf22
1
REQUIRE
1
REQUIRE
|
@ -6,3 +6,4 @@ Highlights
|
||||||
Mustache
|
Mustache
|
||||||
YAML
|
YAML
|
||||||
Compat 0.25.0
|
Compat 0.25.0
|
||||||
|
Plots
|
||||||
|
|
22
src/run.jl
22
src/run.jl
|
@ -152,7 +152,6 @@ function embed_figures(result_chunks, cwd)
|
||||||
return result_chunks
|
return result_chunks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function img2base64(fig, cwd)
|
function img2base64(fig, cwd)
|
||||||
ext = splitext(fig)[2]
|
ext = splitext(fig)[2]
|
||||||
f = open(joinpath(cwd, fig), "r")
|
f = open(joinpath(cwd, fig), "r")
|
||||||
|
@ -211,7 +210,7 @@ function run_code(chunk::CodeChunk, report::Report, SandBox::Module)
|
||||||
for (str_expr, expr) = expressions
|
for (str_expr, expr) = expressions
|
||||||
reset_report(report)
|
reset_report(report)
|
||||||
lastline = (result_no == N)
|
lastline = (result_no == N)
|
||||||
rcParams[:plotlib_set] || detect_plotlib(chunk) #Try to autodetect plotting library
|
rcParams[:plotlib_set] || detect_plotlib(chunk, SandBox) #Try to autodetect plotting library
|
||||||
(obj, out) = capture_output(expr, SandBox, chunk.options[:term],
|
(obj, out) = capture_output(expr, SandBox, chunk.options[:term],
|
||||||
chunk.options[:display], rcParams[:plotlib], lastline, report.throw_errors)
|
chunk.options[:display], rcParams[:plotlib], lastline, report.throw_errors)
|
||||||
figures = report.figures #Captured figures
|
figures = report.figures #Captured figures
|
||||||
|
@ -492,15 +491,16 @@ function collect_results(chunk::CodeChunk, fmt::CollectResult)
|
||||||
return [chunk]
|
return [chunk]
|
||||||
end
|
end
|
||||||
|
|
||||||
function detect_plotlib(chunk::CodeChunk)
|
function detect_plotlib(chunk::CodeChunk, mod)
|
||||||
|
|
||||||
if isdefined(Base, :Plots)
|
if isdefined(mod, :Plots)
|
||||||
init_plotting("Plots")
|
init_plotting("Plots")
|
||||||
#Need to set size before plots are created
|
@info("Init Plots")
|
||||||
Compat.invokelatest(plots_set_size, chunk)
|
#Need to set size before plots are created
|
||||||
return
|
Compat.invokelatest(plots_set_size, chunk)
|
||||||
end
|
return
|
||||||
|
end
|
||||||
|
|
||||||
isdefined(Base, :PyPlot) && init_plotting("PyPlot") && return
|
isdefined(mod, :PyPlot) && init_plotting("PyPlot") && return
|
||||||
isdefined(Base, :Gadfly) && init_plotting("Gadfly") && return
|
isdefined(mod, :Gadfly) && init_plotting("Gadfly") && return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue