Merge branch 'pgfplotsx' of github.com:BeastyBlacksmith/Plots.jl into pgfplotsx

This commit is contained in:
Simon Christ 2019-11-18 11:41:39 +01:00
commit 881d415f21

View File

@ -32,6 +32,15 @@ const _pgfplotsx_legend_pos = KW(
:outertopright => "outer north east",
)
const _pgfx_series_extrastyle = KW(
:steppre => "const plot mark right",
:stepmid => "const plot mark mid",
:steppost => "const plot",
:sticks => "ycomb",
:ysticks => "ycomb",
:xsticks => "xcomb",
)
const _pgfx_framestyles = [:box, :axes, :origin, :zerolines, :grid, :none]
const _pgfx_framestyle_defaults = Dict(:semi => :box)
@ -64,7 +73,7 @@ function pgfx_fillstyle(plotattributes, i = 1)
if fa !== nothing
a = fa
end
fill => cstr, fill_opacity => a
PGFPlotsX.Options("fill" => cstr, "fill opacity" => a)
end
function pgfx_linestyle(linewidth::Real, color, α = 1, linestyle = "solid")
@ -232,21 +241,18 @@ function pgf_series(sp::Subplot, series::Series)
series_collection
end
function pgf_fillrange_series(series, i, fillrange, args...)
function pgfx_fillrange_series!(opt, series, i, fillrange, args...)
st = series[:seriestype]
style = []
kw = KW()
push!(style, "line width = 0")
push!(style, "draw opacity = 0")
push!(style, pgf_fillstyle(series, i))
push!(style, pgf_marker(series, i))
push!(style, "forget plot")
if haskey(_pgf_series_extrastyle, st)
push!(style, _pgf_series_extrastyle[st])
push!(opt, "line width" => 0)
push!(opt, "draw opacity" => 0)
push!(opt, pgfx_fillopt(series, i))
push!(opt, pgfx_marker(series, i))
push!(opt, "forget plot" => nothing)
if haskey(_pgfx_series_extraopt, st)
push!(opt, _pgfx_series_extrastyle[st] => nothing)
end
kw[:style] = join(style, ',')
func = is3d(series) ? PGFPlots.Linear3 : PGFPlots.Linear
return func(pgf_fillrange_args(fillrange, args...)...; kw...)
# TODO: what are those fillrange_args about?
# return func(pgf_fillrange_args(fillrange, args...)...; kw...)
end
function pgf_fillrange_args(fillrange, x, y)
@ -456,19 +462,44 @@ if n_calls === 0
)
for series in series_list(sp)
opt = series.plotattributes
st = series[:seriestype]
series_opt = PGFPlotsX.Options(
"color" => opt[:linecolor]
)
segments = iter_segments(series)
segment_opt = PGFPlotsX.Options()
for (i, rng) in enumerate(segments)
# TODO: make segmented series
segment_opt = merge( segment_opt, pgfx_linestyle(opt, i) )
segment_opt = merge( segment_opt, pgfx_marker(opt, i) )
if st == :shape
segment_opt = merge( segment_opt, pgfx_fillstyle(opt, i) )
end
# TODO: is this necessary?
# seg_args = (arg[rng] for arg in args)
# TODO: translate this
# # add fillrange
# if series[:fillrange] !== nothing && st != :shape
# push!(series_collection, pgf_fillrange_series(series, i, _cycle(series[:fillrange], rng), seg_args...))
# end
end
#include additional style
if haskey(_pgfx_series_extrastyle, st)
push!(series_opt, _pgfx_series_extrastyle[st] => nothing)
end
# TODO: different seriestypes, histogramms, contours, etc.
series_plot = PGFPlotsX.Plot(
merge(
PGFPlotsX.Options(
"color" => opt[:linecolor]
),
pgfx_marker(opt, i)
),
PGFPlotsX.Coordinates(series[:x],series[:y])
# TODO: colorbars
# TODO: gradients
if is3d(series)
series_func = opt -> PGFPlotsX.Plot3(opt,
PGFPlotsX.Coordinates(series[:x],series[:y],series[:z])
)
else
series_func = opt -> PGFPlotsX.Plot(opt,
PGFPlotsX.Coordinates(series[:x],series[:y])
)
end
series_plot = series_func(
merge(series_opt, segment_opt),
)
# add series annotations
anns = series[:series_annotations]