tests for 3D colorbar
This commit is contained in:
parent
6d3e8fcb81
commit
c2c1c9d738
@ -57,7 +57,7 @@ const _pgfx_annotation_halign = KW(
|
||||
function pgfx_colormap(grad::ColorGradient)
|
||||
join(map(grad.colors) do c
|
||||
@sprintf("rgb=(%.8f,%.8f,%.8f)", red(c), green(c),blue(c))
|
||||
end,", ")
|
||||
end,"\n")
|
||||
end
|
||||
|
||||
function pgfx_framestyle(style::Symbol)
|
||||
@ -441,6 +441,8 @@ end
|
||||
function _update_plot_object(plt::Plot{PGFPlotsXBackend})
|
||||
plt.o = PGFPlotsX.GroupPlot()
|
||||
|
||||
pushed_colormap = false
|
||||
empty!(PGFPlotsX.CUSTOM_PREAMBLE)
|
||||
for sp in plt.subplots
|
||||
bb = bbox(sp)
|
||||
legpos = sp[:legend]
|
||||
@ -477,8 +479,15 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend})
|
||||
for series in series_list(sp)
|
||||
for col in (:markercolor, :fillcolor, :linecolor)
|
||||
if typeof(series.plotattributes[col]) == ColorGradient
|
||||
# TODO: fix this
|
||||
# pushed_colormap || push!(PGFPlotsX.CUSTOM_PREAMBLE, """\\pgfplotsset{
|
||||
# colormap={plots}{$(pgfx_colormap(series.plotattributes[col]))},
|
||||
# }""")
|
||||
pushed_colormap = true
|
||||
push!(axis_opt,
|
||||
"colormap" => "{plots}{$(pgfx_colormap(series.plotattributes[col]))}")
|
||||
# "colormap" => nothing,
|
||||
# "colormap name" => "plots",
|
||||
)
|
||||
|
||||
# TODO: is this needed?
|
||||
# if sp[:colorbar] == :none
|
||||
|
||||
@ -2,12 +2,31 @@ using Plots, Test
|
||||
pgfplotsx()
|
||||
|
||||
function create_plot( args...; kwargs... )
|
||||
pgfx_plot = plot(args..., kwargs...)
|
||||
pgfx_plot = plot(args...; kwargs...)
|
||||
return pgfx_plot, repr("application/x-tex", pgfx_plot)
|
||||
end
|
||||
|
||||
function create_plot!( args...; kwargs... )
|
||||
pgfx_plot = plot!(args...; kwargs...)
|
||||
return pgfx_plot, repr("application/x-tex", pgfx_plot)
|
||||
end
|
||||
|
||||
@testset "PGFPlotsX" begin
|
||||
pgfx_plot, pgfx_tex = create_plot(1:5)
|
||||
|
||||
|
||||
@test pgfx_plot.o isa PGFPlotsX.GroupPlot
|
||||
@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)
|
||||
@show PGFPlotsX.CUSTOM_PREAMBLE
|
||||
@show PGFPlotsX.CUSTOM_PREAMBLE_PATH
|
||||
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, "colormap") == true)
|
||||
@test pgfx_plot.o.contents[1]["colormap"] === nothing
|
||||
end
|
||||
end # testset
|
||||
end # testset
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user