Restore fill between functions (#2374)

* skeleton

* remove groupplots

* working insets, fix background opacity

* insets resp. to window

* only shift

* a shift solution

* remove frames

* fix padding

* format code

* Revert "skeleton" restore fill between functions

This reverts commit 80903a2789ec65b5e95e3148122dbf6d36e5e238.

* correct location
This commit is contained in:
Simon Christ 2020-01-29 14:49:19 +01:00 committed by GitHub
parent 84a8039022
commit 2b6a90766a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,16 +221,22 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
end end
axis = axisf(axis_opt) axis = axisf(axis_opt)
for (series_index, series) in enumerate(series_list(sp)) for (series_index, series) in enumerate(series_list(sp))
# give each series a uuid for fillbetween
series_id = uuid4()
_pgfplotsx_series_ids[Symbol("$series_index")] = series_id
opt = series.plotattributes opt = series.plotattributes
st = series[:seriestype] st = series[:seriestype]
series_opt = PGFPlotsX.Options("color" => single_color(opt[:linecolor]),) sf = series[:fillrange]
series_opt = PGFPlotsX.Options(
"color" => single_color(opt[:linecolor]),
"name path" => string(series_id)
)
if is3d(series) || st == :heatmap if is3d(series) || st == :heatmap
series_func = PGFPlotsX.Plot3 series_func = PGFPlotsX.Plot3
else else
series_func = PGFPlotsX.Plot series_func = PGFPlotsX.Plot
end end
if series[:fillrange] !== nothing && if sf !== nothing && !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 == :heatmap
@ -278,20 +284,12 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
if st == :shape || isfilledcontour(series) if st == :shape || isfilledcontour(series)
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 series[:fillrange] !== nothing && if sf !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing
!isfilledcontour(series) && series[:ribbon] === nothing if sf isa Number || sf isa AVec
pgfx_fillrange_series!( pgfx_fillrange_series!( axis, series, series_func, i, _cycle(sf, rng), rng)
axis, end
series, if i == 1 && opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
series_func,
i,
_cycle(series[:fillrange], rng),
rng,
)
if i == 1 &&
opt[:label] != "" &&
sp[:legend] != :none && should_add_to_legend(series)
pgfx_filllegend!(series_opt, opt) pgfx_filllegend!(series_opt, opt)
end end
end end
@ -309,6 +307,15 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
coordinates, coordinates,
) )
push!(axis, segment_plot) push!(axis, segment_plot)
# fill between functions
if sf isa Tuple && series[:ribbon] === nothing
sf1, sf2 = sf
@assert sf1 == series_index "First index of the tuple has to match the current series index."
push!(axis, series_func(
merge(pgfx_fillstyle(opt, series_index), PGFPlotsX.Options("forget plot" => nothing)),
"fill between [of=$series_id and $(_pgfplotsx_series_ids[Symbol(string(sf2))])]"
))
end
# add ribbons? # add ribbons?
ribbon = series[:ribbon] ribbon = series[:ribbon]
if ribbon !== nothing if ribbon !== nothing
@ -343,25 +350,18 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
) )
end end
end end
# add subplot annotations # add subplot annotations
anns = sp.attr[:annotations] for ann in sp[:annotations]
for (xi, yi, txt) in anns pgfx_add_annotation!(axis, locate_annotation(sp, ann...)..., pgfx_thickness_scaling(sp))
pgfx_add_annotation!(
axis,
xi,
yi,
txt,
pgfx_thickness_scaling(sp),
)
end end
end end # for series
push!(the_plot, axis) push!(the_plot, axis)
if length(plt.o.the_plot.elements) > 0 if length(plt.o.the_plot.elements) > 0
plt.o.the_plot.elements[1] = the_plot plt.o.the_plot.elements[1] = the_plot
else else
push!(plt.o, the_plot) push!(plt.o, the_plot)
end end
end end # for subplots
pgfx_plot.is_created = true pgfx_plot.is_created = true
end # if end # if
return pgfx_plot return pgfx_plot