Skip to content

Commit 213a762

Browse files
committed
Add PGFPlotsX.jl integration
1 parent 11050a7 commit 213a762

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ julia = "1.2"
3030
[extras]
3131
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
3232
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
33+
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
3334
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
3435
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3536

src/Weave.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ weave_info() = WEAVE_VERSION, string(Date(now()))
2525
function __init__()
2626
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" include("integrations/Plots.jl")
2727
@require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" include("integrations/Gadfly.jl")
28+
@require PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" include("integrations/PGFPlotsX.jl")
2829
end
2930

3031
# utilitity functions

src/display_methods.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const mimetype_ext = Dict(
3232
".pdf" => "application/pdf",
3333
".ps" => "application/postscript",
3434
".tex" => "text/latex",
35+
".tikz" => "text/tikz",
3536
)
3637

3738
function Base.display(report::Report, data)

src/integrations/PGFPlotsX.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module PGFPlotsXPlots
2+
3+
using ..Weave, ..PGFPlotsX
4+
5+
function Base.display(report::Weave.Report, m::MIME"application/pdf", figure::PGFPlotsX.AxisLike)
6+
7+
chunk = report.cur_chunk
8+
9+
ext = chunk.options[:fig_ext]
10+
dpi = chunk.options[:dpi]
11+
12+
full_name, rel_name = Weave.get_figname(report, chunk, ext = ext)
13+
14+
# if ext in [".tikz", ".TIKZ", ".TikZ", ".pgf", ".PGF"]
15+
if ext == ".tikz"
16+
pgfsave(full_name, figure; include_preamble = false, dpi = dpi)
17+
end
18+
19+
if ext == ".tex"
20+
pgfsave(full_name, figure; include_preamble = true, dpi = dpi)
21+
end
22+
23+
push!(report.figures, rel_name)
24+
report.fignum += 1
25+
return full_name
26+
end
27+
28+
end # PGFPlotsXPlots

0 commit comments

Comments
 (0)