2014-12-03 14:41:53 +01:00
|
|
|
using Gadfly
|
|
|
|
|
|
|
|
Gadfly.set_default_plot_format(:png)
|
|
|
|
|
2014-12-04 15:14:07 +01:00
|
|
|
#Captures figures
|
2014-12-04 20:54:56 +01:00
|
|
|
function Base.display(report::Report, m::MIME"image/png", p::Plot)
|
|
|
|
|
2016-04-20 19:23:00 +02:00
|
|
|
chunk = report.cur_chunk
|
2014-12-04 15:14:07 +01:00
|
|
|
full_name, rel_name = get_figname(report, chunk)
|
2014-12-03 22:34:29 +01:00
|
|
|
|
|
|
|
docformat = formats[report.formatdict[:doctype]]
|
2016-04-20 19:23:00 +02:00
|
|
|
push!(report.figures, rel_name)
|
2014-12-03 22:34:29 +01:00
|
|
|
|
2014-12-04 15:14:07 +01:00
|
|
|
report.fignum += 1
|
2014-12-04 20:54:56 +01:00
|
|
|
|
2015-01-05 15:35:24 +01:00
|
|
|
w = chunk.options[:fig_width]inch
|
|
|
|
h = chunk.options[:fig_height]inch
|
|
|
|
format = chunk.options[:fig_ext]
|
|
|
|
dpi = chunk.options[:dpi]
|
2014-12-05 09:37:02 +01:00
|
|
|
|
|
|
|
#This is probably not the correct way to handle different formats, but it works.
|
|
|
|
if format == ".png"
|
2014-12-18 12:44:37 +01:00
|
|
|
try
|
2015-01-05 15:35:24 +01:00
|
|
|
draw(PNG(full_name, w, h, dpi=dpi), p)
|
2014-12-18 12:44:37 +01:00
|
|
|
catch
|
2015-01-05 15:35:24 +01:00
|
|
|
draw(PNG(full_name, w, h), p) #Compose < 0.3.1, Gadfly < 0.3.1
|
2014-12-18 12:44:37 +01:00
|
|
|
end
|
2015-01-08 18:06:43 +01:00
|
|
|
elseif format == ".pdf"
|
|
|
|
draw(PDF(full_name, w, h), p)
|
|
|
|
elseif format == ".ps"
|
|
|
|
draw(PS(full_name, w, h), p)
|
|
|
|
elseif format == ".svg"
|
|
|
|
draw(SVG(full_name, w, h), p)
|
|
|
|
elseif format == ".js.svg"
|
|
|
|
draw(SVGJS(full_name, w, h), p)
|
|
|
|
elseif format == ".tex"
|
|
|
|
draw(PGF(full_name, w, h, true ), p)
|
|
|
|
else:
|
|
|
|
warn("Can't save figure. Unsupported format")
|
2014-12-05 09:37:02 +01:00
|
|
|
end
|
2014-12-03 14:41:53 +01:00
|
|
|
end
|