Skip to content

Commit

Permalink
Begin PGFPlotsX.jl integration
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranOMara committed Oct 5, 2021
1 parent fd103cc commit b573c42
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ julia = "1.2"
[extras]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand Down
1 change: 1 addition & 0 deletions src/Weave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ weave_info() = WEAVE_VERSION, string(Date(now()))
function __init__()
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" include("integrations/Plots.jl")
@require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" include("integrations/Gadfly.jl")
@require PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" include("integrations/PGFPlotsX.jl")
end

# utilitity functions
Expand Down
1 change: 1 addition & 0 deletions src/display_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mimetype_ext = Dict(
".pdf" => "application/pdf",
".ps" => "application/postscript",
".tex" => "text/latex",
".tikz" => "text/tikz",
)

function Base.display(report::Report, data)
Expand Down
28 changes: 28 additions & 0 deletions src/integrations/PGFPlotsX.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module PGFPlotsXPlots

using ..Weave, ..PGFPlotsX

function Base.display(report::Weave.Report, m::MIME"application/pdf", figure::PGFPlotsX.Axis)

chunk = report.cur_chunk

ext = chunk.options[:fig_ext]
dpi = chunk.options[:dpi]

full_name, rel_name = Weave.get_figname(report, chunk, ext = ext)

# if ext in [".tikz", ".TIKZ", ".TikZ", ".pgf", ".PGF"]
if ext == ".tikz"
pgfsave(full_name, figure; include_preamble = false, dpi = dpi)
end

if ext == ".tex"
pgfsave(full_name, figure; include_preamble = true, dpi = dpi)
end

push!(report.figures, rel_name)
report.fignum += 1
return full_name
end

end # PGFPlotsXPlots

0 comments on commit b573c42

Please sign in to comment.