fix filled contours (colorbar is off)

This commit is contained in:
Simon Christ 2020-05-11 13:36:34 +02:00
parent 10bb9a145d
commit cb90773340
2 changed files with 8 additions and 17 deletions

View File

@ -288,7 +288,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
extra_series = wraptuple(pop!(extra_series_opt,:add)) extra_series = wraptuple(pop!(extra_series_opt,:add))
end end
series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...)) series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...))
if RecipesPipeline.is3d(series) || st == :heatmap if RecipesPipeline.is3d(series) || st in (:heatmap, :contour)
series_func = PGFPlotsX.Plot3 series_func = PGFPlotsX.Plot3
else else
series_func = PGFPlotsX.Plot series_func = PGFPlotsX.Plot
@ -342,12 +342,13 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
end end
segment_opt = merge(segment_opt, pgfx_marker(opt, i)) segment_opt = merge(segment_opt, pgfx_marker(opt, i))
end end
if st == :shape || isfilledcontour(series) if st == :shape
segment_opt = merge(segment_opt, pgfx_fillstyle(opt, i)) segment_opt = merge(segment_opt, pgfx_fillstyle(opt, i))
end end
# add fillrange # add fillrange
if sf !== nothing && if sf !== nothing &&
!isfilledcontour(series) && series[:ribbon] === nothing !isfilledcontour(series) &&
series[:ribbon] === nothing
if sf isa Number || sf isa AVec if sf isa Number || sf isa AVec
pgfx_fillrange_series!( pgfx_fillrange_series!(
axis, axis,
@ -596,8 +597,8 @@ function pgfx_series_coordinates!(
xs, ys, zs = collect(args) xs, ys, zs = collect(args)
push!( push!(
segment_opt, segment_opt,
"contour filled" => PGFPlotsX.Options("labels" => opt[:contour_labels]), "contour filled" => PGFPlotsX.Options(), # labels not supported
"point meta" => "explicit", "patch type" => "bilinear",
"shader" => "flat", "shader" => "flat",
) )
if opt[:levels] isa Number if opt[:levels] isa Number
@ -606,17 +607,7 @@ function pgfx_series_coordinates!(
push!(segment_opt["contour filled"], "levels" => opt[:levels]) push!(segment_opt["contour filled"], "levels" => opt[:levels])
end end
cs = join( PGFPlotsX.Coordinates(args...)
[
join(["($x, $y) [$(zs[j, i])]" for (j, x) in enumerate(xs)], " ") for (i, y) in enumerate(ys)
],
"\n\n",
)
"""
coordinates {
$cs
};
"""
end end
## ##
pgfx_get_linestyle(k) = get( pgfx_get_linestyle(k) = get(

View File

@ -487,7 +487,7 @@ end
hascolorbar(series::Series) = colorbar_style(series) !== nothing hascolorbar(series::Series) = colorbar_style(series) !== nothing
hascolorbar(sp::Subplot) = sp[:colorbar] != :none && any(hascolorbar(s) for s in series_list(sp)) hascolorbar(sp::Subplot) = sp[:colorbar] != :none && any(hascolorbar(s) for s in series_list(sp))
iscontour(series::Series) = series[:seriestype] == :contour iscontour(series::Series) = series[:seriestype] in (:contour, :contour3d)
isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !== nothing isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !== nothing
function contour_levels(series::Series, clims) function contour_levels(series::Series, clims)