Skip to content

Commit 6f6de2b

Browse files
committed
Add PGFPlotsX.jl integration
1 parent 639f276 commit 6f6de2b

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module PGFPlotsXPlots
2+
3+
using ..Weave, ..PGFPlotsX
4+
5+
Base.showable(m::MIME"text/latex", plot::PGFPlotsX.AxisLike) = true
6+
Base.showable(m::MIME"text/tikz", plot::PGFPlotsX.AxisLike) = true
7+
8+
function Base.display(report::Weave.Report, m::MIME"text/latex", figure::PGFPlotsX.AxisLike)
9+
10+
chunk = report.cur_chunk
11+
12+
ext = chunk.options[:fig_ext]
13+
dpi = chunk.options[:dpi]
14+
15+
full_name, rel_name = Weave.get_figname(report, chunk, ext = ext)
16+
17+
pgfsave(full_name, figure; include_preamble = true, dpi = dpi)
18+
19+
push!(report.figures, rel_name)
20+
report.fignum += 1
21+
return full_name
22+
end
23+
24+
function Base.display(report::Weave.Report, m::MIME"text/tikz", figure::PGFPlotsX.AxisLike)
25+
26+
chunk = report.cur_chunk
27+
28+
ext = chunk.options[:fig_ext]
29+
dpi = chunk.options[:dpi]
30+
31+
full_name, rel_name = Weave.get_figname(report, chunk, ext = ext)
32+
33+
pgfsave(full_name, figure; include_preamble = false, dpi = dpi)
34+
35+
push!(report.figures, rel_name)
36+
report.fignum += 1
37+
return full_name
38+
end
39+
40+
end # PGFPlotsXPlots

0 commit comments

Comments
 (0)