diff --git a/Project.toml b/Project.toml index 7bbeea7..4487acc 100644 --- a/Project.toml +++ b/Project.toml @@ -9,7 +9,6 @@ NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Requires = "ae029012-a4dd-5104-9daa-d747884805df" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d" [compat] CSV = "0.10" @@ -17,14 +16,4 @@ LaTeXStrings = "^1.3" NaNMath = "0.3, 1" Requires = "1" Tables = "1.11" -TikzPictures = "3.5" julia = "^1.6" - -[extras] -PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" - -[targets] -test = ["PGFPlotsX", "Plots", "Test", "UnicodePlots"] diff --git a/src/BenchmarkProfiles.jl b/src/BenchmarkProfiles.jl index a95d7ab..38b6340 100644 --- a/src/BenchmarkProfiles.jl +++ b/src/BenchmarkProfiles.jl @@ -29,9 +29,10 @@ for backend ∈ bp_backends end end + export_performance_profile_tikz(args...;kwargs...) = error("Please load TikzPictures.jl package to access this function.") + include("performance_profiles.jl") include("data_profiles.jl") -include("tikz_export.jl") """ Replace each number by 2^{number} in a string. diff --git a/src/requires.jl b/src/requires.jl index ea1627a..490aaca 100644 --- a/src/requires.jl +++ b/src/requires.jl @@ -181,4 +181,8 @@ function __init__() return profile end end + + @require TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d" begin + include("tikz_export.jl") + end end diff --git a/src/tikz_export.jl b/src/tikz_export.jl index 48b9671..d516f0a 100644 --- a/src/tikz_export.jl +++ b/src/tikz_export.jl @@ -1,11 +1,7 @@ -using TikzPictures - -export export_performance_profile_tikz - """ function export_performance_profile_tikz(T, filename; kwargs...) -Export tikz figure of the performance profiles given by `T` in `filename`. +Export tikz-generated figure of the performance profiles given by `T` in `filename`. ## Arguments @@ -42,7 +38,7 @@ Other keyword arguments are passed to `performance_profile_data`. function export_performance_profile_tikz( T::Matrix{Float64}, filename::String; - file_type = TIKZ, + file_type = TikzPictures.TIKZ, solvernames::Vector{String} = String[], xlim::AbstractFloat = 10.0, ylim::AbstractFloat = 10.0, @@ -161,6 +157,12 @@ function export_performance_profile_tikz( drawcmd *= ";" println(io, drawcmd) end + + # legend box + println( + io, + "\\draw[line width=$linewidth,fill=white] ($(lgd_pos[1]),$(lgd_pos[2])) rectangle ($(lgd_pos[1]+lgd_box_length),$(lgd_pos[2]-lgd_v_offset*(length(solvernames)+1)));", + ) # legend for j in eachindex(solvernames) legcmd = "\\draw[$(colours[j]), $(linestyles[j]), line width = $linewidth] " @@ -172,13 +174,8 @@ function export_performance_profile_tikz( println(io, legcmd) end - # legend box - println( - io, - "\\draw[line width=$linewidth] ($(lgd_pos[1]),$(lgd_pos[2])) -- ($(lgd_pos[1]+lgd_box_length),$(lgd_pos[2])) -- ($(lgd_pos[1]+lgd_box_length),$(lgd_pos[2]-lgd_v_offset*(length(solvernames)+1))) -- ($(lgd_pos[1]),$(lgd_pos[2]-lgd_v_offset*(length(solvernames)+1))) -- cycle;", - ) raw_code = String(take!(io)) - tp = TikzPicture(raw_code) - save(file_type(filename), tp) + tp = TikzPictures.TikzPicture(raw_code) + TikzPictures.save(file_type(filename), tp) end diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..6ab36f3 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,14 @@ +[deps] +LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" +Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d" +UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" + +[compat] +LaTeXStrings = "^1.3" +PGFPlotsX = "1.6" +Plots = "1.39" +TikzPictures = "3.5" +UnicodePlots = "3.6" \ No newline at end of file