mirror of https://github.com/mpastell/Weave.jl
Add saving pngs and pdf for plotlyjs Plots backend
parent
d50770abe1
commit
68a8fbdcf4
|
@ -20,6 +20,7 @@ end
|
|||
|
||||
#Default mimetypes in order, can be overridden for some inside `run method` formats
|
||||
const default_mime_types = ["image/svg+xml", "image/png", "text/html", "text/plain"]
|
||||
#const default_mime_types = ["image/png", "image/svg+xml", "text/html", "text/plain"]
|
||||
#From IJulia as a reminder
|
||||
#const supported_mime_types = [ "text/html", "text/latex", "image/svg+xml", "image/png", "image/jpeg", "text/plain", "text/markdown" ]
|
||||
|
||||
|
@ -40,21 +41,21 @@ end
|
|||
function Base.display(report::Report, m::MIME"image/png", data)
|
||||
figname = add_figure(report, ".png")
|
||||
open(figname, "w") do io
|
||||
writemime(io, m, data)
|
||||
show(io, m, data)
|
||||
end
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"image/svg+xml", data)
|
||||
figname = add_figure(report, ".svg")
|
||||
open(figname, "w") do io
|
||||
writemime(io, m, data)
|
||||
show(io, m, data)
|
||||
end
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"application/pdf", data)
|
||||
figname = add_figure(report, ".pdf")
|
||||
open(figname, "w") do io
|
||||
writemime(io, m, data)
|
||||
show(io, m, data)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -201,9 +201,9 @@ const md2html = Pandoc("Markdown to HTML (requires Pandoc)",
|
|||
:codeend=> "````\n\n",
|
||||
:outputstart=> "````",
|
||||
:outputend=> "````\n\n",
|
||||
:fig_ext=> ".svg",
|
||||
:fig_ext=> ".png",
|
||||
:extension=> "md",
|
||||
:mimetypes => ["image/svg+xml", "image/png", "image/jpg",
|
||||
:mimetypes => ["image/png", "image/svg+xml", "image/jpg",
|
||||
"text/html", "text/markdown", "text/plain"],
|
||||
:doctype=> "md2html"))
|
||||
|
||||
|
|
16
src/plots.jl
16
src/plots.jl
|
@ -9,3 +9,19 @@ function plots_set_size(chunk)
|
|||
end
|
||||
|
||||
push_preexecute_hook(plots_set_size)
|
||||
|
||||
function Base.display(report::Report, m::MIME"image/png", data::Plots.Plot)
|
||||
Plots.gui(data) #Required for savefig to work
|
||||
chunk = report.cur_chunk
|
||||
full_name, rel_name = get_figname(report, chunk)
|
||||
push!(report.figures, rel_name)
|
||||
Plots.savefig(data, full_name)
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"application/pdf", data::Plots.Plot)
|
||||
Plots.gui(data)
|
||||
chunk = report.cur_chunk
|
||||
full_name, rel_name = get_figname(report, chunk)
|
||||
push!(report.figures, rel_name)
|
||||
Plots.savefig(data, full_name)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue