common add_series
This commit is contained in:
parent
8bede094ba
commit
d8d14a77ec
@ -288,129 +288,6 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
push!(series_opt, "area legend" => nothing)
|
push!(series_opt, "area legend" => nothing)
|
||||||
end
|
end
|
||||||
pgfx_add_series!(Val(st), axis, series_opt, series, series_func, opt)
|
pgfx_add_series!(Val(st), axis, series_opt, series, series_func, opt)
|
||||||
# if st in (:heatmap, :contour)
|
|
||||||
# push!(axis.options, "view" => "{0}{90}")
|
|
||||||
# end
|
|
||||||
# # treat segments
|
|
||||||
# segments =
|
|
||||||
# if st in (:wireframe, :heatmap, :contour, :surface, :contour3d)
|
|
||||||
# iter_segments(surface_to_vecs(
|
|
||||||
# series[:x],
|
|
||||||
# series[:y],
|
|
||||||
# series[:z],
|
|
||||||
# )...)
|
|
||||||
# else
|
|
||||||
# iter_segments(series)
|
|
||||||
# end
|
|
||||||
# for (i, rng) in enumerate(segments)
|
|
||||||
# segment_opt = PGFPlotsX.Options()
|
|
||||||
# segment_opt = merge(segment_opt, pgfx_linestyle(opt, i))
|
|
||||||
# if opt[:markershape] != :none
|
|
||||||
# marker = opt[:markershape]
|
|
||||||
# if marker isa Shape
|
|
||||||
# x = marker.x
|
|
||||||
# y = marker.y
|
|
||||||
# scale_factor = 0.00125
|
|
||||||
# mark_size = opt[:markersize] * scale_factor
|
|
||||||
# path = join(
|
|
||||||
# [
|
|
||||||
# "($(x[i] * mark_size), $(y[i] * mark_size))"
|
|
||||||
# for i in eachindex(x)
|
|
||||||
# ],
|
|
||||||
# " -- ",
|
|
||||||
# )
|
|
||||||
# c = get_markercolor(series, i)
|
|
||||||
# a = get_markeralpha(series, i)
|
|
||||||
# PGFPlotsX.push_preamble!(
|
|
||||||
# pgfx_plot.the_plot,
|
|
||||||
# """
|
|
||||||
# \\pgfdeclareplotmark{PlotsShape$(series_index)}{
|
|
||||||
# \\filldraw
|
|
||||||
# $path;
|
|
||||||
# }
|
|
||||||
# """,
|
|
||||||
# )
|
|
||||||
# end
|
|
||||||
# segment_opt = merge(segment_opt, pgfx_marker(opt, i))
|
|
||||||
# end
|
|
||||||
# if st == :shape
|
|
||||||
# segment_opt = merge(segment_opt, pgfx_fillstyle(opt, i))
|
|
||||||
# end
|
|
||||||
# # add fillrange
|
|
||||||
# if sf !== nothing &&
|
|
||||||
# !isfilledcontour(series)
|
|
||||||
# if sf isa Number || sf isa AVec
|
|
||||||
# pgfx_fillrange_series!(
|
|
||||||
# axis,
|
|
||||||
# series,
|
|
||||||
# series_func,
|
|
||||||
# i,
|
|
||||||
# _cycle(sf, rng),
|
|
||||||
# rng,
|
|
||||||
# )
|
|
||||||
# elseif sf isa Tuple && series[:ribbon] !== nothing
|
|
||||||
# for sfi in sf
|
|
||||||
# pgfx_fillrange_series!(
|
|
||||||
# axis,
|
|
||||||
# series,
|
|
||||||
# series_func,
|
|
||||||
# i,
|
|
||||||
# _cycle(sfi, rng),
|
|
||||||
# rng,
|
|
||||||
# )
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# if i == 1 &&
|
|
||||||
# sp[:legend] != :none && pgfx_should_add_to_legend(series)
|
|
||||||
# pgfx_filllegend!(series_opt, opt)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# coordinates =
|
|
||||||
# pgfx_series_coordinates!(sp, series, segment_opt, opt, rng)
|
|
||||||
# segment_plot =
|
|
||||||
# series_func(merge(series_opt, segment_opt), coordinates)
|
|
||||||
# if extra_series !== nothing
|
|
||||||
# extra_series = wraptuple(extra_series)
|
|
||||||
# push!(segment_plot, extra_series...)
|
|
||||||
# end
|
|
||||||
# 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 to legend?
|
|
||||||
# if sp[:legend] != :none
|
|
||||||
# leg_entry = if opt[:label] isa AVec
|
|
||||||
# get(opt[:label], i, "")
|
|
||||||
# elseif opt[:label] isa AbstractString
|
|
||||||
# if i == 1
|
|
||||||
# get(opt, :label, "")
|
|
||||||
# else
|
|
||||||
# ""
|
|
||||||
# end
|
|
||||||
# else
|
|
||||||
# throw(ArgumentError("Malformed label. label = $(opt[:label])"))
|
|
||||||
# end
|
|
||||||
# if leg_entry == "" || !pgfx_should_add_to_legend(series)
|
|
||||||
# push!(axis.contents[end].options, "forget plot" => nothing)
|
|
||||||
# else
|
|
||||||
# leg_opt = PGFPlotsX.Options()
|
|
||||||
# legend = PGFPlotsX.LegendEntry(leg_opt, leg_entry, false)
|
|
||||||
# push!(axis, legend)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end # for segments
|
|
||||||
if extra_series !== nothing
|
if extra_series !== nothing
|
||||||
extra_series = wraptuple(extra_series)
|
extra_series = wraptuple(extra_series)
|
||||||
push!(axis.contents[end], extra_series...)
|
push!(axis.contents[end], extra_series...)
|
||||||
@ -448,6 +325,13 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
return pgfx_plot
|
return pgfx_plot
|
||||||
end
|
end
|
||||||
## seriestype specifics
|
## seriestype specifics
|
||||||
|
function pgfx_add_series!(axis, series_opt, series, series_func, opt)
|
||||||
|
args = pgfx_series_arguments(series, opt)
|
||||||
|
series_plot = series_func(series_opt, PGFPlotsX.Coordinates(args...))
|
||||||
|
push!(axis, series_plot)
|
||||||
|
pgfx_add_legend!(axis, series, opt)
|
||||||
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, opt)
|
||||||
# treat segments
|
# treat segments
|
||||||
segments = iter_segments(series)
|
segments = iter_segments(series)
|
||||||
@ -561,18 +445,14 @@ function pgfx_add_series!(::Val{:surface}, axis, series_opt, series, series_func
|
|||||||
"mesh/cols" => length(opt[:y]),
|
"mesh/cols" => length(opt[:y]),
|
||||||
"z buffer" => "sort",
|
"z buffer" => "sort",
|
||||||
)
|
)
|
||||||
args = pgfx_series_arguments(series, opt)
|
pgfx_add_series!(axis, series_opt, series, series_func, opt)
|
||||||
series_plot = series_func(series_opt, PGFPlotsX.Coordinates(args...))
|
|
||||||
push!(axis, series_plot)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:wireframe}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:wireframe}, axis, series_opt, series, series_func, opt)
|
||||||
push!(series_opt, "mesh" => nothing,
|
push!(series_opt, "mesh" => nothing,
|
||||||
"mesh/rows" => length(opt[:x])
|
"mesh/rows" => length(opt[:x])
|
||||||
)
|
)
|
||||||
args = pgfx_series_arguments(series, opt)
|
pgfx_add_series!(axis, series_opt, series, series_func, opt)
|
||||||
series_plot = series_func(series_opt, PGFPlotsX.Coordinates(args...))
|
|
||||||
push!(axis, series_plot)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:heatmap}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:heatmap}, axis, series_opt, series, series_func, opt)
|
||||||
@ -583,9 +463,7 @@ function pgfx_add_series!(::Val{:heatmap}, axis, series_opt, series, series_func
|
|||||||
"mesh/rows" => length(opt[:x]),
|
"mesh/rows" => length(opt[:x]),
|
||||||
"mesh/cols" => length(opt[:y]),
|
"mesh/cols" => length(opt[:y]),
|
||||||
)
|
)
|
||||||
args = pgfx_series_arguments(series, opt)
|
pgfx_add_series!(axis, series_opt, series, series_func, opt)
|
||||||
series_plot = series_func(series_opt, PGFPlotsX.Coordinates(args...))
|
|
||||||
push!(axis, series_plot)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:contour}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:contour}, axis, series_opt, series, series_func, opt)
|
||||||
@ -608,10 +486,7 @@ function pgfx_add_series!(::Val{:filledcontour}, axis, series_opt, series, serie
|
|||||||
elseif opt[:levels] isa AVec
|
elseif opt[:levels] isa AVec
|
||||||
push!(segment_opt["contour filled"], "levels" => opt[:levels])
|
push!(segment_opt["contour filled"], "levels" => opt[:levels])
|
||||||
end
|
end
|
||||||
|
pgfx_add_series!(axis, series_opt, series, series_func, opt)
|
||||||
args = pgfx_series_arguments(series, opt)
|
|
||||||
series_plot = series_func(series_opt, PGFPlotsX.Coordinates(args...))
|
|
||||||
push!(axis, series_plot)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:contour3d}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:contour3d}, axis, series_opt, series, series_func, opt)
|
||||||
@ -622,6 +497,7 @@ function pgfx_add_series!(::Val{:contour3d}, axis, series_opt, series, series_fu
|
|||||||
args = pgfx_series_arguments(series, opt)
|
args = pgfx_series_arguments(series, opt)
|
||||||
series_plot = series_func(series_opt, PGFPlotsX.Table(Contour.contours(args..., opt[:levels])))
|
series_plot = series_func(series_opt, PGFPlotsX.Table(Contour.contours(args..., opt[:levels])))
|
||||||
push!(axis, series_plot)
|
push!(axis, series_plot)
|
||||||
|
pgfx_add_legend!(axis, series, opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:quiver}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:quiver}, axis, series_opt, series, series_func, opt)
|
||||||
@ -645,6 +521,7 @@ function pgfx_add_series!(::Val{:quiver}, axis, series_opt, series, series_func,
|
|||||||
end
|
end
|
||||||
series_plot = series_func(series_opt, table)
|
series_plot = series_func(series_opt, table)
|
||||||
push!(axis, series_plot)
|
push!(axis, series_plot)
|
||||||
|
pgfx_add_legend!(axis, series, opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pgfx_add_series!(::Val{:shape}, axis, series_opt, series, series_func, opt)
|
function pgfx_add_series!(::Val{:shape}, axis, series_opt, series, series_func, opt)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user