fix and format pgfx-tests
This commit is contained in:
parent
acac178d8a
commit
7cb4d42fac
@ -302,6 +302,11 @@ end
|
||||
lines = readlines(io)
|
||||
@test count(s -> occursin("node", s), lines) == 9
|
||||
end
|
||||
# test .tikz extension
|
||||
file_path = joinpath(path, "annotations.tikz")
|
||||
@test_nowarn savefig(annotation_plot, file_path)
|
||||
@test_nowarn open(file_path) do io
|
||||
end
|
||||
end
|
||||
end # testset
|
||||
@testset "Ribbon" begin
|
||||
@ -321,6 +326,18 @@ end
|
||||
@test ribbon_plot.o !== nothing
|
||||
@test ribbon_plot.o.the_plot !== nothing
|
||||
end # testset
|
||||
@testset "Markers and Paths" begin
|
||||
pl = plot(
|
||||
5 .- ones(9),
|
||||
markershape = [:utriangle, :rect],
|
||||
markersize = 8,
|
||||
color = [:red, :black],
|
||||
)
|
||||
Plots._update_plot_object(pl)
|
||||
axis = Plots.pgfx_axes(pl.o)[1]
|
||||
plots = filter(x -> x isa PGFPlotsX.Plot, axis.contents)
|
||||
@test length(plots) == 9
|
||||
end # testset
|
||||
end # testset
|
||||
|
||||
@testset "Extra kwargs" begin
|
||||
@ -330,15 +347,65 @@ end # testset
|
||||
@test pl[1].attr[:extra_kwargs][:test] == "me"
|
||||
pl = plot(1:5, test = "me", extra_kwargs = :plot)
|
||||
@test pl.attr[:extra_plot_kwargs][:test] == "me"
|
||||
pl = plot(1:5, extra_kwargs = Dict(:plot => Dict(:test => "me"), :series => Dict(:and => "me too")))
|
||||
pl = plot(
|
||||
1:5,
|
||||
extra_kwargs = Dict(
|
||||
:plot => Dict(:test => "me"),
|
||||
:series => Dict(:and => "me too"),
|
||||
),
|
||||
)
|
||||
@test pl.attr[:extra_plot_kwargs][:test] == "me"
|
||||
@test pl[1][1].plotattributes[:extra_kwargs][:and] == "me too"
|
||||
pl = plot(
|
||||
plot(1:5, title = "Line"),
|
||||
scatter(1:5, title="Scatter", extra_kwargs=Dict(:subplot=>Dict("axis line shift" => "10pt")))
|
||||
scatter(
|
||||
1:5,
|
||||
title = "Scatter",
|
||||
extra_kwargs = Dict(:subplot => Dict("axis line shift" => "10pt")),
|
||||
),
|
||||
)
|
||||
Plots._update_plot_object(pl)
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test !haskey(axes[1].options.dict, "axis line shift")
|
||||
@test haskey(axes[2].options.dict, "axis line shift")
|
||||
pl = plot(
|
||||
x -> x,
|
||||
-1:1;
|
||||
add = raw"\node at (0,0.5) {\huge hi};",
|
||||
extra_kwargs = :subplot,
|
||||
)
|
||||
@test pl[1][:extra_kwargs] == Dict(:add => raw"\node at (0,0.5) {\huge hi};")
|
||||
Plots._update_plot_object(pl)
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test filter(x -> x isa String, axes[1].contents)[1] ==
|
||||
raw"\node at (0,0.5) {\huge hi};"
|
||||
plot!(pl)
|
||||
@test pl[1][:extra_kwargs] == Dict(:add => raw"\node at (0,0.5) {\huge hi};")
|
||||
Plots._update_plot_object(pl)
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test filter(x -> x isa String, axes[1].contents)[1] ==
|
||||
raw"\node at (0,0.5) {\huge hi};"
|
||||
end # testset
|
||||
|
||||
@testset "Titlefonts" begin
|
||||
pl = plot(1:5, title = "Test me", titlefont = (2, :left))
|
||||
@test pl[1][:title] == "Test me"
|
||||
@test pl[1][:titlefontsize] == 2
|
||||
@test pl[1][:titlefonthalign] == :left
|
||||
Plots._update_plot_object(pl)
|
||||
ax_opt = Plots.pgfx_axes(pl.o)[1].options
|
||||
@test ax_opt["title"] == "Test me"
|
||||
@test(haskey(ax_opt.dict, "title style")) isa Test.Pass
|
||||
pl = plot(1:5, plot_title = "Test me", plot_titlefont = (2, :left))
|
||||
@test pl[:plot_title] == "Test me"
|
||||
@test pl[:plot_titlefontsize] == 2
|
||||
@test pl[:plot_titlefonthalign] == :left
|
||||
pl = heatmap(
|
||||
rand(3, 3),
|
||||
colorbar_title = "Test me",
|
||||
colorbar_titlefont = (12, :right),
|
||||
)
|
||||
@test pl[1][:colorbar_title] == "Test me"
|
||||
@test pl[1][:colorbar_titlefontsize] == 12
|
||||
@test pl[1][:colorbar_titlefonthalign] == :right
|
||||
end # testset
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user