mirror of https://github.com/mpastell/Weave.jl
commit
244cb9ab17
|
@ -26,9 +26,10 @@ const default_mime_types = ["image/svg+xml", "image/png", "text/html", "text/pla
|
|||
function Base.display(report::Report, data)
|
||||
#Set preferred mimetypes for report based on format
|
||||
for m in report.mimetypes
|
||||
info(m)
|
||||
if mimewritable(m, data)
|
||||
display(report, m, data)
|
||||
#Always use plain text for term mode
|
||||
#Always show plain text as well for term mode
|
||||
if m ≠ "text/plain" && report.cur_chunk.options[:term]
|
||||
display(report, "text/plain", data)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,8 @@ using Gadfly
|
|||
|
||||
Gadfly.set_default_plot_format(:svg)
|
||||
|
||||
#Captures figures
|
||||
#Gadfly doesn't call the default display methods, this catches
|
||||
#all Gadfly plots
|
||||
function Base.display(report::Report, m::MIME"image/svg+xml", p::Plot)
|
||||
|
||||
chunk = report.cur_chunk
|
||||
|
|
|
@ -1,21 +1,47 @@
|
|||
import Winston
|
||||
import Base.mimewritable
|
||||
|
||||
function save_winston(report, data)
|
||||
chunk = report.cur_chunk
|
||||
full_name, rel_name = get_figname(report, chunk)
|
||||
|
||||
docformat = formats[report.formatdict[:doctype]]
|
||||
push!(report.figures, rel_name)
|
||||
report.fignum += 1
|
||||
vector_fmts = [".pdf"; ".svg"]
|
||||
#Don't use dpi for vector formats
|
||||
if chunk.options[:fig_ext] in vector_fmts
|
||||
Winston.savefig(data, full_name, width=chunk.options[:fig_width]*100,
|
||||
height=chunk.options[:fig_height]*100)
|
||||
else
|
||||
Winston.savefig(data, full_name,
|
||||
width=chunk.options[:fig_width]*chunk.options[:dpi],
|
||||
height=chunk.options[:fig_height]*chunk.options[:dpi])
|
||||
end
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"image/svg+xml", data::Winston.FramedPlot)
|
||||
|
||||
chunk = report.cur_chunk
|
||||
full_name, rel_name = get_figname(report, chunk)
|
||||
|
||||
docformat = formats[report.formatdict[:doctype]]
|
||||
push!(report.figures, rel_name)
|
||||
report.fignum += 1
|
||||
vector_fmts = [".pdf"; ".svg"]
|
||||
#Don't use dpi for vector formats
|
||||
if chunk.options[:fig_ext] in vector_fmts
|
||||
Winston.savefig(data, full_name, width=chunk.options[:fig_width]*100,
|
||||
height=chunk.options[:fig_height]*100)
|
||||
else
|
||||
Winston.savefig(data, full_name,
|
||||
width=chunk.options[:fig_width]*chunk.options[:dpi],
|
||||
height=chunk.options[:fig_height]*chunk.options[:dpi])
|
||||
end
|
||||
save_winston(report, data)
|
||||
end
|
||||
|
||||
function Base.mimewritable(m::MIME"application/pdf", data::Winston.FramedPlot)
|
||||
return true
|
||||
end
|
||||
|
||||
function Base.mimewritable(m::MIME"image/svg+xml", data::Winston.FramedPlot)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
function Base.display(report::Report, m::MIME"application/pdf", data::Winston.FramedPlot)
|
||||
save_winston(report, data)
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"image/png", data::Winston.FramedPlot)
|
||||
save_winston(report, data)
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"image/jpg", data::Winston.FramedPlot)
|
||||
save_winston(report, data)
|
||||
end
|
||||
|
|
|
@ -51,11 +51,6 @@ display(p)
|
|||
````
|
||||
|
||||
|
||||
````
|
||||
warning: sub-optimal solution for plot
|
||||
````
|
||||
|
||||
|
||||
![](figures/winston_formats_3_1.png)
|
||||
|
||||
````julia
|
||||
|
|
|
@ -62,12 +62,6 @@ Winston.FramedPlot(...)
|
|||
|
||||
|
||||
|
||||
::
|
||||
|
||||
warning: sub-optimal solution for plot
|
||||
|
||||
|
||||
|
||||
.. image:: figures/winston_formats_3_1.png
|
||||
:width: 15 cm
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ julia> plot(t, sinc(t))
|
|||
|
||||
Winston.FramedPlot(...)
|
||||
\end{juliaterm}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_1_1.png}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_1_1.pdf}
|
||||
|
||||
\begin{juliaterm}
|
||||
julia> s = 1:10
|
||||
|
@ -18,7 +18,7 @@ julia> s = 1:10
|
|||
julia> plot(s, "r*")
|
||||
Winston.FramedPlot(...)
|
||||
\end{juliaterm}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_1_2.png}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_1_2.pdf}
|
||||
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ Winston.FramedPlot(...)
|
|||
|
||||
\begin{figure}[htpb]
|
||||
\center
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_random_1.png}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_random_1.pdf}
|
||||
\caption{Random walk.}
|
||||
\label{fig:random}
|
||||
\end{figure}
|
||||
|
@ -50,10 +50,7 @@ add(p, Curve(x, s, color="blue"))
|
|||
display(p)
|
||||
|
||||
\end{juliacode}
|
||||
\begin{juliaout}
|
||||
warning: sub-optimal solution for plot
|
||||
\end{juliaout}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_3_1.png}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_3_1.pdf}
|
||||
|
||||
\begin{juliacode}
|
||||
|
||||
|
@ -82,4 +79,4 @@ l = Legend(.1, .9, {a,b,s})
|
|||
add(p, s, a, b, l)
|
||||
display(p)
|
||||
\end{juliacode}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_3_2.png}
|
||||
\includegraphics[width=\linewidth]{figures/winston_formats_3_2.pdf}
|
||||
|
|
|
@ -11,7 +11,7 @@ Winston.FramedPlot(...)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/winston_formats_1_1.png)\
|
||||
![](figures/winston_formats_1_1.svg)\
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
|
@ -23,14 +23,14 @@ Winston.FramedPlot(...)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/winston_formats_1_2.png)\
|
||||
![](figures/winston_formats_1_2.svg)\
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
![Random walk.](figures/winston_formats_random_1.png)
|
||||
![Random walk.](figures/winston_formats_random_1.svg)
|
||||
|
||||
|
||||
|
||||
|
@ -53,12 +53,7 @@ display(p)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
~~~~
|
||||
warning: sub-optimal solution for plot
|
||||
~~~~
|
||||
|
||||
|
||||
![](figures/winston_formats_3_1.png)\
|
||||
![](figures/winston_formats_3_1.svg)\
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
|
@ -90,5 +85,5 @@ display(p)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/winston_formats_3_2.png)\
|
||||
![](figures/winston_formats_3_2.svg)\
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ if VERSION < v"0.5-dev"
|
|||
include("chunk_opts_gadfly.jl")
|
||||
|
||||
#Fails on travis, works locally.
|
||||
#info("Test: Weaving with Winston")
|
||||
#include("winston_formats.jl")
|
||||
info("Test: Weaving with Winston")
|
||||
include("winston_formats.jl")
|
||||
|
||||
info("Test: Weaving with Gadfly")
|
||||
include("gadfly_formats.jl")
|
||||
|
|
Loading…
Reference in New Issue