allow disabling the colorbar in pgfplotsx

This commit is contained in:
Daniel Schwabeneder 2020-05-13 15:15:42 +02:00
parent 238aca6a78
commit 0a6e691222

View File

@ -206,41 +206,42 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
# As it is likely that all series within the same axis use the same # As it is likely that all series within the same axis use the same
# colormap this should not cause any problem. # colormap this should not cause any problem.
for series in series_list(sp) for series in series_list(sp)
if hascolorbar(series) if hascolorbar(series)
cg = get_colorgradient(series) cg = get_colorgradient(series)
cm = pgfx_colormap(get_colorgradient(series)) cm = pgfx_colormap(get_colorgradient(series))
PGFPlotsX.push_preamble!( PGFPlotsX.push_preamble!(
pgfx_plot.the_plot, pgfx_plot.the_plot,
"""\\pgfplotsset{ """\\pgfplotsset{
colormap={plots$(sp.attr[:subplot_index])}{$cm}, colormap={plots$(sp.attr[:subplot_index])}{$cm},
}""", }""",
) )
if sp[:colorbar] == true
push!(axis_opt, "colorbar" => nothing)
end
push!(axis_opt, "colormap name" => "plots$(sp.attr[:subplot_index])")
if cg isa PlotUtils.CategoricalColorGradient
push!( push!(
axis_opt, axis_opt,
"colorbar" => nothing, "colormap access" => "piecewise const",
"colormap name" => "plots$(sp.attr[:subplot_index])", "colorbar sampled" => nothing,
) )
if cg isa PlotUtils.CategoricalColorGradient
push!(
axis_opt,
"colormap access" => "piecewise const",
"colorbar sampled" => nothing,
)
end
# goto is needed to break out of col and series for
@goto colorbar_end
end end
# goto is needed to break out of col and series for
@goto colorbar_end
end
end end
@label colorbar_end @label colorbar_end
push!( if sp[:colorbar] == true
axis_opt, push!(
"colorbar style" => PGFPlotsX.Options( axis_opt,
"title" => sp[:colorbar_title], "colorbar style" => PGFPlotsX.Options(
), "title" => sp[:colorbar_title],
"point meta max" => get_clims(sp)[2], ),
"point meta min" => get_clims(sp)[1], "point meta max" => get_clims(sp)[2],
) "point meta min" => get_clims(sp)[1],
)
end
if RecipesPipeline.is3d(sp) if RecipesPipeline.is3d(sp)
azim, elev = sp[:camera] azim, elev = sp[:camera]
push!(axis_opt, "view" => (azim, elev)) push!(axis_opt, "view" => (azim, elev))