apply annotations

This commit is contained in:
Simon Christ 2019-11-15 13:47:04 +01:00
parent 6b6d589aa7
commit 86643058b6

View File

@ -135,7 +135,7 @@ end
function pgf_series(sp::Subplot, series::Series) function pgf_series(sp::Subplot, series::Series)
plotattributes = series.plotattributes plotattributes = series.plotattributes
st = plotattributes[:seriestype] st = plotattributes[:seriestype]
series_collection = PGFPlots.Plot[] series_collection = PGFPlotsX.Plot[]
# function args # function args
args = if st == :contour args = if st == :contour
@ -154,11 +154,11 @@ function pgf_series(sp::Subplot, series::Series)
end end
# PGFPlots can't handle non-Vector? # PGFPlots can't handle non-Vector?
args = map(a -> if typeof(a) <: AbstractVector && typeof(a) != Vector # args = map(a -> if typeof(a) <: AbstractVector && typeof(a) != Vector
collect(a) # collect(a)
else # else
a # a
end, args) # end, args)
if st in (:contour, :histogram2d) if st in (:contour, :histogram2d)
style = [] style = []
@ -452,17 +452,24 @@ function _update_plot_object(plt::Plot{PGFPlotsXBackend})
opt = series.plotattributes opt = series.plotattributes
segments = iter_segments(series) segments = iter_segments(series)
for (i, rng) in enumerate(segments) for (i, rng) in enumerate(segments)
series_plot = PGFPlotsX.Plot( # TODO: make segmented series
merge(
PGFPlotsX.Options(
"color" => opt[:linecolor]
),
pgfx_marker(opt, i)
),
PGFPlotsX.Coordinates(series[:x],series[:y])
)
push!( axis, series_plot )
end 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])
)
# add series annotations
anns = series[:series_annotations]
for (xi,yi,str,fnt) in EachAnn(anns, series[:x], series[:y])
pgfx_add_annotation!(series_plot, xi, yi, PlotText(str, fnt), pgfx_thickness_scaling(series))
end
push!( axis, series_plot )
if opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series) if opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
push!( axis, PGFPlotsX.LegendEntry( opt[:label] ) push!( axis, PGFPlotsX.LegendEntry( opt[:label] )
) )