update tests
This commit is contained in:
parent
faf905a932
commit
a2bdc4c3ef
@ -5,6 +5,8 @@ Base.@kwdef mutable struct PGFPlotsXPlot
|
||||
the_plot::PGFPlotsX.TikzDocument = PGFPlotsX.TikzDocument()
|
||||
end
|
||||
|
||||
pgfx_axes(pgfx_plot::PGFPlotsXPlot) = pgfx_plot.the_plot.elements[1].elements[1].contents
|
||||
|
||||
function Base.show(io::IO, mime::MIME, pgfx_plot::PGFPlotsXPlot)
|
||||
show(io::IO, mime, pgfx_plot.the_plot)
|
||||
end
|
||||
@ -31,7 +33,6 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
a = alpha(cstr)
|
||||
title_cstr = plot_color(sp[:titlefontcolor])
|
||||
title_a = alpha(cstr)
|
||||
# TODO: aspect ratio
|
||||
axis_opt = PGFPlotsX.Options(
|
||||
"height" => string(height(bb)),
|
||||
"width" => string(width(bb)),
|
||||
@ -575,7 +576,7 @@ end
|
||||
|
||||
function _show(io::IO, mime::MIME"application/x-tex", plt::Plot{PGFPlotsXBackend})
|
||||
_update_plot_object(plt)
|
||||
PGFPlotsX.print_tex(plt.o)
|
||||
PGFPlotsX.print_tex(plt.o.the_plot)
|
||||
end
|
||||
|
||||
function _display(plt::Plot{PGFPlotsXBackend})
|
||||
|
||||
@ -12,34 +12,37 @@ function create_plot!( args...; kwargs... )
|
||||
end
|
||||
|
||||
@testset "PGFPlotsX" begin
|
||||
pgfx_plot, pgfx_tex = create_plot(1:5)
|
||||
pgfx_plot = plot(1:5)
|
||||
Plots._update_plot_object(pgfx_plot)
|
||||
@test pgfx_plot.o.the_plot isa PGFPlotsX.TikzDocument
|
||||
|
||||
@test pgfx_plot.o isa PGFPlotsX.GroupPlot
|
||||
@testset "3D docs example" begin
|
||||
@testset "3D docs example" begin
|
||||
n = 100
|
||||
ts = range(0, stop=8π, length=n)
|
||||
x = ts .* map(cos, ts)
|
||||
y = (0.1ts) .* map(sin, ts)
|
||||
z = 1:n
|
||||
pl = plot(x, y, z, zcolor=reverse(z), m=(10, 0.8, :blues, Plots.stroke(0)), leg=false, cbar=true, w=5)
|
||||
pgfx_plot, pgfx_tex = create_plot!(pl, zeros(n), zeros(n), 1:n, w=10)
|
||||
if @test_nowarn(haskey(pgfx_plot.o.contents[1].options.dict, "colorbar") == true)
|
||||
@test pgfx_plot.o.contents[1]["colorbar"] === nothing
|
||||
pgfx_plot = plot!(pl, zeros(n), zeros(n), 1:n, w=10)
|
||||
Plots._update_plot_object(pgfx_plot)
|
||||
if @test_nowarn(haskey(Plots.pgfx_axes(pgfx_plot.o)[1].options.dict, "colorbar") == true)
|
||||
@test Plots.pgfx_axes(pgfx_plot.o)[1]["colorbar"] === nothing
|
||||
end
|
||||
end # testset
|
||||
@testset "Color docs example" begin
|
||||
y = rand(100)
|
||||
plot(0:10:100, rand(11, 4), lab="lines", w=3, palette=:grays, fill=0, α=0.6)
|
||||
scatter!(y, zcolor=abs.(y .- 0.5), m=(:heat, 0.8, Plots.stroke(1, :green)), ms=10 * abs.(y .- 0.5) .+ 4, lab="grad")
|
||||
pl = scatter!(y, zcolor=abs.(y .- 0.5), m=(:heat, 0.8, Plots.stroke(1, :green)), ms=10 * abs.(y .- 0.5) .+ 4, lab="grad")
|
||||
Plots._update_plot_object(pl)
|
||||
axis = Plots.pgfx_axes(pl.o)[1]
|
||||
@test count( x->x isa PGFPlotsX.LegendEntry, axis.contents ) == 5
|
||||
@test count( x->x isa PGFPlotsX.Plot, axis.contents ) == 5
|
||||
# TODO: marker size does not adjust
|
||||
# TODO: marker stroke is incorrect
|
||||
# TODO: fill legends
|
||||
# TODO: adjust colorbar limits to data
|
||||
end # testset
|
||||
@testset "Plot in pieces" begin
|
||||
plot(rand(100) / 3, reg=true, fill=(0, :green))
|
||||
scatter!(rand(100), markersize=6, c=:orange)
|
||||
# TODO: legends should be different
|
||||
end # testset
|
||||
@testset "Marker types" begin
|
||||
markers = filter((m->begin
|
||||
@ -50,7 +53,6 @@ end
|
||||
x = (range(0, stop=10, length=n + 2))[2:end - 1]
|
||||
y = repeat(reshape(reverse(x), 1, :), n, 1)
|
||||
scatter(x, y, m=(8, :auto), lab=map(string, markers), bg=:linen, xlim=(0, 10), ylim=(0, 10))
|
||||
#TODO: fix markers that show up as circles
|
||||
end # testset
|
||||
@testset "Layout" begin
|
||||
plot(Plots.fakedata(100, 10), layout=4, palette=[:grays :blues :heat :lightrainbow], bg_inside=[:orange :pink :darkblue :black])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user