fix contours (#2692)
* fix 2d-contour * fix filled contours (colorbar is off) * activate fixed examples
This commit is contained in:
parent
1963cee94a
commit
219465d599
@ -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
|
||||||
@ -297,7 +297,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
!isfilledcontour(series) && series[:ribbon] === nothing
|
!isfilledcontour(series) && series[:ribbon] === nothing
|
||||||
push!(series_opt, "area legend" => nothing)
|
push!(series_opt, "area legend" => nothing)
|
||||||
end
|
end
|
||||||
if st == :heatmap
|
if st in (:heatmap, :contour)
|
||||||
push!(axis.options, "view" => "{0}{90}")
|
push!(axis.options, "view" => "{0}{90}")
|
||||||
end
|
end
|
||||||
# treat segments
|
# treat segments
|
||||||
@ -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(
|
||||||
|
|||||||
@ -998,13 +998,11 @@ _backend_skips = Dict(
|
|||||||
6, # images
|
6, # images
|
||||||
10, # histogram2d
|
10, # histogram2d
|
||||||
16, # pgfplots thinks the upper panel is too small
|
16, # pgfplots thinks the upper panel is too small
|
||||||
22, # contourf
|
|
||||||
25, # @df
|
25, # @df
|
||||||
30, # @df
|
30, # @df
|
||||||
31, # animation
|
31, # animation
|
||||||
32, # spy
|
32, # spy
|
||||||
38, # histogram2d
|
38, # histogram2d
|
||||||
45, # wireframe
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user