direct colormap access

This commit is contained in:
Simon Christ 2019-11-26 00:07:45 +01:00
parent f2af121661
commit 091ca327ba
2 changed files with 9 additions and 7 deletions

View File

@ -158,6 +158,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
push!(axis_opt, push!(axis_opt,
"colorbar" => nothing, "colorbar" => nothing,
"colormap name" => "plots$(sp.attr[:subplot_index])", "colormap name" => "plots$(sp.attr[:subplot_index])",
"colormap access" => "direct",
) )
# goto is needed to break out of col and series for # goto is needed to break out of col and series for
@goto colorbar_end @goto colorbar_end
@ -192,7 +193,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
series_opt = PGFPlotsX.Options( series_opt = PGFPlotsX.Options(
"color" => single_color(opt[:linecolor]), "color" => single_color(opt[:linecolor]),
) )
if is3d(series) || st == :heatmap #|| isfilledcontour(series) if is3d(series) || st == :heatmap
series_func = PGFPlotsX.Plot3 series_func = PGFPlotsX.Plot3
else else
series_func = PGFPlotsX.Plot series_func = PGFPlotsX.Plot
@ -336,7 +337,7 @@ function pgfx_series_coordinates!(st_val::Val{:heatmap}, segment_opt, opt, args)
push!(segment_opt, push!(segment_opt,
"surf" => nothing, "surf" => nothing,
"mesh/rows" => length(opt[:x]), "mesh/rows" => length(opt[:x]),
"mesh/cols" => length(opt[:y]) "mesh/cols" => length(opt[:y]),
) )
return PGFPlotsX.Table(args...) return PGFPlotsX.Table(args...)
end end

View File

@ -80,7 +80,8 @@ end
z = float((1:4) * reshape(1:10, 1, :)) z = float((1:4) * reshape(1:10, 1, :))
pgfx_plot = heatmap(xs, ys, z, aspect_ratio=1) pgfx_plot = heatmap(xs, ys, z, aspect_ratio=1)
Plots._update_plot_object(pgfx_plot) Plots._update_plot_object(pgfx_plot)
if @test_nowarn(haskey(Plots.pgfx_axes(pgfx_plot.o)[1].options.dict, "colorbar") == true) 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 @test Plots.pgfx_axes(pgfx_plot.o)[1]["colorbar"] === nothing
@test Plots.pgfx_axes(pgfx_plot.o)[1]["colormap name"] == "plots1" @test Plots.pgfx_axes(pgfx_plot.o)[1]["colormap name"] == "plots1"
end end