🔥 Plots.jl/Gadfly.jl integration test

pull/373/head
Shuhei Kadowaki 2020-06-14 02:24:25 +09:00
parent 7d6fddc749
commit 2070610a58
25 changed files with 3 additions and 610 deletions

View File

@ -26,11 +26,10 @@ YAML = "0.3, 0.4"
julia = "1.2"
[extras]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Cairo", "DataFrames", "Gadfly", "Plots", "Test"]
test = ["DataFrames", "Test"]

View File

@ -1,18 +0,0 @@
~~~~{.julia}
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
~~~~~~~~~~~~~
![sin(x) function.](figures/gadfly_formats_test_sin_fun_1.js.svg){#fig:sin_fun}
![cos(x) function.](figures/gadfly_formats_test_2_1.js.svg)
~~~~{.julia}
plot(x=x, y = cos.(2x), Geom.line)
~~~~~~~~~~~~~
![](figures/gadfly_formats_test_cos2_fun_1.js.svg){width=15cm #fig:cos2_fun}\

View File

@ -1,17 +0,0 @@
````julia
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
````
![sin(x) function.](figures/gadfly_formats_test_sin_fun_1.pdf)
![cos(x) function.](figures/gadfly_formats_test_2_1.pdf)
````julia
plot(x=x, y = cos.(2x), Geom.line)
````
![](figures/gadfly_formats_test_cos2_fun_1.pdf)

View File

@ -1,17 +0,0 @@
````julia
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
````
![sin(x) function.](figures/gadfly_formats_test_sin_fun_1.png)
![cos(x) function.](figures/gadfly_formats_test_2_1.png)
````julia
plot(x=x, y = cos.(2x), Geom.line)
````
![](figures/gadfly_formats_test_cos2_fun_1.png)

View File

@ -1,18 +0,0 @@
~~~~{.julia}
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
~~~~~~~~~~~~~
![sin(x) function.](figures/gadfly_formats_test_sin_fun_1.png){#fig:sin_fun}
![cos(x) function.](figures/gadfly_formats_test_2_1.png)
~~~~{.julia}
plot(x=x, y = cos.(2x), Geom.line)
~~~~~~~~~~~~~
![](figures/gadfly_formats_test_cos2_fun_1.png){width=15cm #fig:cos2_fun}\

View File

@ -1,17 +0,0 @@
````julia
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
````
![sin(x) function.](figures/gadfly_formats_test_sin_fun_1.svg)
![cos(x) function.](figures/gadfly_formats_test_2_1.svg)
````julia
plot(x=x, y = cos.(2x), Geom.line)
````
![](figures/gadfly_formats_test_cos2_fun_1.svg)

View File

@ -1,22 +0,0 @@
\begin{juliacode}
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
\end{juliacode}
\begin{figure}[ht]
\center
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_sin_fun_1.pdf}
\caption{sin(x) function.}
\label{fig:sin_fun}
\end{figure}
\begin{figure}[htpb]
\center
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_2_1.pdf}
\caption{cos(x) function.}
\end{figure}
\begin{juliacode}
plot(x=x, y = cos.(2x), Geom.line)
\end{juliacode}
\includegraphics[width=15cm]{figures/gadfly_formats_test_cos2_fun_1.pdf}

View File

@ -1,22 +0,0 @@
\begin{juliacode}
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
\end{juliacode}
\begin{figure}[ht]
\center
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_sin_fun_1.png}
\caption{sin(x) function.}
\label{fig:sin_fun}
\end{figure}
\begin{figure}[htpb]
\center
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_2_1.png}
\caption{cos(x) function.}
\end{figure}
\begin{juliacode}
plot(x=x, y = cos.(2x), Geom.line)
\end{juliacode}
\includegraphics[width=15cm]{figures/gadfly_formats_test_cos2_fun_1.png}

View File

@ -1,22 +0,0 @@
\begin{juliacode}
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
\end{juliacode}
\begin{figure}[ht]
\center
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_sin_fun_1.ps}
\caption{sin(x) function.}
\label{fig:sin_fun}
\end{figure}
\begin{figure}[htpb]
\center
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_2_1.ps}
\caption{cos(x) function.}
\end{figure}
\begin{juliacode}
plot(x=x, y = cos.(2x), Geom.line)
\end{juliacode}
\includegraphics[width=15cm]{figures/gadfly_formats_test_cos2_fun_1.ps}

View File

@ -1,22 +0,0 @@
\begin{juliacode}
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
\end{juliacode}
\begin{figure}[ht]
\center
\resizebox{\linewidth}{!}{\input{figures/gadfly_formats_test_sin_fun_1.tex}}
\caption{sin(x) function.}
\label{fig:sin_fun}
\end{figure}
\begin{figure}[htpb]
\center
\resizebox{\linewidth}{!}{\input{figures/gadfly_formats_test_2_1.tex}}
\caption{cos(x) function.}
\end{figure}
\begin{juliacode}
plot(x=x, y = cos.(2x), Geom.line)
\end{juliacode}
\resizebox{15cm}{!}{\input{figures/gadfly_formats_test_cos2_fun_1.tex}}

View File

@ -1,19 +0,0 @@
---
weave_options:
out_path: gadfly
---
<<fig_cap="sin(x) function."; label="sin_fun"; fig_pos="ht">>=
using Gadfly
x = range(0, stop =2π, step=0.05)
plot(x=x, y = sin.(x), Geom.line)
@
<<echo=false; fig_cap="cos(x) function."; dpi=200>>=
plot(x=x, y = cos.(x), Geom.line)
@
<<label="cos2_fun"; out_width="15cm">>=
plot(x=x, y = cos.(2x), Geom.line)
@

View File

@ -1,12 +0,0 @@
# Gadfly
```{julia;fig_ext=".svg";dpi=300}
using Gadfly
x = collect(range(0, stop=2π, length=200))
plot(
layer(x=x, y = sin.(x), Geom.line),
layer(x=x, y = cos.(x), Geom.line, Theme(default_color=colorant"red")),
Guide.manual_color_key("Legend", ["sin", "cos"], ["deepskyblue", "red"])
)
```

View File

@ -1,22 +0,0 @@
<div class="Random plot">
<p>Some inline output</p>
<pre class='hljl'>
<span class='hljl-nf'>println</span><span class='hljl-p'>(</span><span class='hljl-s'>&quot;Testing output&quot;</span><span class='hljl-p'>)</span>
</pre>
<pre class="output">
Testing output
</pre>
</div>

View File

@ -1,22 +0,0 @@
\begin{frame}[fragile]
\frametitle{Random plot}
Some inline output
\begin{lstlisting}
(*@\HLJLnf{println}@*)(*@\HLJLp{(}@*)(*@\HLJLs{"{}Testing}@*) (*@\HLJLs{output"{}}@*)(*@\HLJLp{)}@*)
\end{lstlisting}
\begin{lstlisting}
Testing output
\end{lstlisting}
\end{frame}

View File

@ -1,16 +0,0 @@
using Plots
pyplot()
x = range(0, stop=2*pi, length=50)
println(x)
p = plot(x = x, y = sin(x), size =(900,300))
plot(x = x, y = sin(x))
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
plot(y = cumsum(randn(1000, 1)))

View File

@ -1,60 +0,0 @@
~~~~{.julia}
using Plots
pyplot()
x = linspace(0, 2*pi)
println(x)
~~~~~~~~~~~~~
~~~~
linspace(0.0,6.283185307179586,50)
~~~~
~~~~{.julia}
p = plot(x, sin(x), size =(900,300))
~~~~~~~~~~~~~
~~~~{.julia}
julia> plot(x, sin(x))
~~~~~~~~~~~~~
![](figures/plotsjl_test_2_1.png)\
~~~~{.julia}
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
~~~~~~~~~~~~~
![](figures/plotsjl_test_3_1.png)\
~~~~{.julia}
julia> plot(rand(100) / 3,reg=true,fill=(0,:green))
~~~~~~~~~~~~~
![](figures/plotsjl_test_4_1.png)\
~~~~{.julia}
julia> scatter!(rand(100),markersize=6,c=:orange)
~~~~~~~~~~~~~
![](figures/plotsjl_test_4_2.png)\
![A random walk.](figures/plotsjl_test_random_1.png)

View File

@ -1,47 +0,0 @@
\begin{juliacode}
using Plots
pyplot()
x = linspace(0, 2*pi)
println(x)
\end{juliacode}
\begin{juliaout}
linspace(0.0,6.283185307179586,50)
\end{juliaout}
\begin{juliacode}
p = plot(x, sin(x), size =(900,300))
\end{juliacode}
\begin{juliaterm}
julia> plot(x, sin(x))
\end{juliaterm}
\includegraphics[width=\linewidth]{figures/plotsjl_test_2_1.pdf}
\begin{juliacode}
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
\end{juliacode}
\includegraphics[width=\linewidth]{figures/plotsjl_test_3_1.pdf}
\begin{juliaterm}
julia> plot(rand(100) / 3,reg=true,fill=(0,:green))
\end{juliaterm}
\includegraphics[width=\linewidth]{figures/plotsjl_test_4_1.pdf}
\begin{juliaterm}
julia> scatter!(rand(100),markersize=6,c=:orange)
\end{juliaterm}
\includegraphics[width=\linewidth]{figures/plotsjl_test_4_2.pdf}
\begin{figure}[htpb]
\center
\includegraphics[width=\linewidth]{figures/plotsjl_test_random_1.pdf}
\caption{A random walk.}
\label{fig:random}
\end{figure}

View File

@ -1,41 +0,0 @@
~~~~{.julia}
using Plots
gr()
x = range(0, stop=2π, length=50)
println(x)
~~~~~~~~~~~~~
~~~~
0.0:0.1282282715750936:6.283185307179586
~~~~
~~~~{.julia}
p = plot(x, sin.(x), size =(900,300))
p
~~~~~~~~~~~~~
![](figures/plotsjl_test_gr_1_1.png)\
~~~~{.julia}
plot(x, sin.(x))
~~~~~~~~~~~~~
![](figures/plotsjl_test_gr_2_1.png)\
~~~~{.julia}
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
~~~~~~~~~~~~~
![](figures/plotsjl_test_gr_3_1.png)\
![A random walk.](figures/plotsjl_test_gr_random_1.png){#fig:random}

View File

@ -1,33 +0,0 @@
\begin{juliacode}
using Plots
gr()
x = range(0, stop=2π, length=50)
println(x)
\end{juliacode}
\begin{juliaout}
0.0:0.1282282715750936:6.283185307179586
\end{juliaout}
\begin{juliacode}
p = plot(x, sin.(x), size =(900,300))
p
\end{juliacode}
\includegraphics[width=\linewidth]{figures/plotsjl_test_gr_1_1.pdf}
\begin{juliacode}
plot(x, sin.(x))
\end{juliacode}
\includegraphics[width=\linewidth]{figures/plotsjl_test_gr_2_1.pdf}
\begin{juliacode}
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
\end{juliacode}
\includegraphics[width=\linewidth]{figures/plotsjl_test_gr_3_1.pdf}
\begin{figure}[htpb]
\center
\includegraphics[width=\linewidth]{figures/plotsjl_test_gr_random_1.pdf}
\caption{A random walk.}
\label{fig:random}
\end{figure}

View File

@ -1,29 +0,0 @@
```julia
using Plots
pyplot()
x = linspace(0, 2*pi)
println(x)
p = plot(x, sin(x), size =(900,300))
```
```julia; term=true
plot(x, sin(x))
```
```julia
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
```
```julia; term=true
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
```
```{julia;echo=false; fig_cap="A random walk."; label="random"}
plot(cumsum(randn(1000, 1)))
```

View File

@ -1,25 +0,0 @@
```julia
using Plots
gr()
x = range(0, stop=2π, length=50)
println(x)
p = plot(x, sin.(x), size =(900,300))
p
```
```julia
plot(x, sin.(x))
```
```julia
plot(rand(100) / 3,reg=true,fill=(0,:green))
scatter!(rand(100),markersize=6,c=:orange)
```
```{julia;echo=false; fig_cap="A random walk."; label="random"}
plot(cumsum(randn(1000, 1), dims=1))
```

View File

@ -1,37 +0,0 @@
y= [2, 5, 12]
x = 1:10
d = Dict("Weave" => "testing")
y = [2, 4 ,8]
x = [12, 10]
println(y)
println(x)
println("Results without code")
println(x)
y = 1:5
println(y)
a = "Don't print me"
println(a)
println("No markup for results.")
println(collect(0:10:1000))
println(collect(0:10:1000))
println(collect(0:10:1000))

View File

@ -1,31 +0,0 @@
# Test for Gadfly with different chunk options and figure formatsusing Weave
using Gadfly, Cairo
function test_gadfly(doctype, fig_ext)
out = weave(
joinpath(@__DIR__ , "documents/gadfly_formats_test.jnw"),
doctype = doctype,
fig_ext = fig_ext
)
result = read(out, String)
# cp(out, out*fig_ext*"."*doctype, force=true) # Used when adding new tests
ref = read(out*fig_ext*"."*doctype, String)
@test result == ref
rm(out)
end
test_gadfly("github", ".png")
test_gadfly("github", ".pdf")
test_gadfly("github", ".svg")
test_gadfly("pandoc", ".png")
test_gadfly("pandoc", ".js.svg")
test_gadfly("tex", ".pdf")
test_gadfly("tex", ".png")
test_gadfly("tex", ".ps")
test_gadfly("tex", ".tex")
p = Gadfly.plot(x=1:10, y=1:10)
@test showable(MIME"application/pdf"(), p) == true
@test showable(MIME"application/png"(), p) == true

View File

@ -1,22 +0,0 @@
using Plots
function pljtest(source, resfile, doctype)
weave("documents/$source", out_path = "documents/plotsjl/$resfile", doctype=doctype)
result = read("documents/plotsjl/$resfile", String)
ref = read("documents/plotsjl/$resfile.ref", String)
@test result == ref
rm("documents/plotsjl/$resfile")
end
pljtest("plotsjl_test_gr.jmd", "plotsjl_test_gr.md", "pandoc")
pljtest("plotsjl_test_gr.jmd", "plotsjl_test_gr.tex", "tex")
# test cache with plots
isdir("documents/cache") && rm("documents/cache", recursive = true)
weave("documents/plotsjl_test_gr.jmd", cache=:all)
result = read("documents/plotsjl_test_gr.html", String)
rm("documents/plotsjl_test_gr.html")
weave("documents/plotsjl_test_gr.jmd", cache=:all)
cached_result = read("documents/plotsjl_test_gr.html", String)
@test result == cached_result

View File

@ -3,6 +3,7 @@
# - test for `include_weave`
# - fire horrible tests
# - test for ipynb integration
# - test for integrations with other libraries, especially for Plots.jl and Gadfly.jl
# %%
using Weave, Test
@ -56,26 +57,10 @@ end
include("test_display.jl")
end
@testset "Formatters" begin
@testset "legacy" begin
include("formatter_test.jl")
include("markdown_test.jl")
include("figureformatter_test.jl")
end
@testset "cache" begin
include("cache_test.jl")
end
# trigger only on CI
if get(ENV, "CI", nothing) == "true"
@testset "Plots" begin
include("plotsjl_test.jl")
end
@testset "Gadfly" begin
include("gadfly_formats.jl")
end
else
@info "skipped Plots.jl and Gadfly.jl integration test"
end
end