free shapes

This commit is contained in:
Simon Christ 2019-11-23 20:10:08 +01:00
parent 607640ce73
commit 2bbaf9d504

View File

@ -158,8 +158,8 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
)
end
# treat segments
segments = if iscontour(series) || st == :heatmap
iter_segments(series[:x], series[:y])
segments = if st in (:wireframe, :heatmap, :contour, :surface)
iter_segments(surface_to_vecs(series[:x], series[:y], series[:z])...)
else
iter_segments(series)
end
@ -167,6 +167,21 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
for (i, rng) in enumerate(segments)
segment_opt = merge( segment_opt, pgfx_linestyle(opt, i) )
if opt[:markershape] != :none #|| !iscontour(series) && !(st == :heatmap)
marker = opt[:markershape]
if marker isa Shape
x = marker.x
y = marker.y
scale_factor = 0.025
mark_size = opt[:markersize] * scale_factor
path = join(["($(x[i] * mark_size), $(y[i] * mark_size))" for i in eachindex(x)], " -- ")
PGFPlotsX.push_preamble!(pgfx_plot.the_plot,
"""
\\pgfdeclareplotmark{PlotsShape}{
\\draw $path;
}
"""
)
end
segment_opt = merge( segment_opt, pgfx_marker(opt, i) )
end
if st == :shape || series[:fillrange] !== nothing
@ -300,8 +315,11 @@ function pgfx_series_coordinates!(st_val::Val{:xsticks}, segment_opt, opt, args)
return PGFPlotsX.Coordinates(args...)
end
function pgfx_series_coordinates!(st_val::Val{:surface}, segment_opt, opt, args)
@show collect(args)[3] |> length
@show args
push!( segment_opt, "surf" => nothing,
"mesh/rows" => length(opt[:x])
"mesh/rows" => length(opt[:x]),
"mesh/cols" => length(opt[:y]),
)
return PGFPlotsX.Coordinates(args...)
end
@ -316,7 +334,7 @@ function pgfx_series_coordinates!(st_val::Val{:wireframe}, segment_opt, opt, arg
return PGFPlotsX.Coordinates(args...)
end
function pgfx_series_coordinates!(st_val::Val{:shape}, segment_opt, opt, args)
push!( segment_opt, "area legends" => nothing, "patch" => nothing )
push!( segment_opt, "area legends" => nothing )
return PGFPlotsX.Coordinates(args...)
end
function pgfx_series_coordinates!(st_val::Val{:contour}, segment_opt, opt, args)
@ -459,9 +477,10 @@ function pgfx_marker(plotattributes, i = 1)
a = alpha(cstr)
cstr_stroke = plot_color(get_markerstrokecolor(plotattributes, i), get_markerstrokealpha(plotattributes, i))
a_stroke = alpha(cstr_stroke)
mark_size = pgfx_thickness_scaling(plotattributes) * 0.5 * _cycle(plotattributes[:markersize], i)
return PGFPlotsX.Options(
"mark" => get(_pgfplotsx_markers, shape, "*"),
"mark size" => pgfx_thickness_scaling(plotattributes) * 0.5 * _cycle(plotattributes[:markersize], i),
"mark" => shape isa Shape ? "PlotsShape" : get(_pgfplotsx_markers, shape, "*"),
"mark size" => "$mark_size pt",
"mark options" => PGFPlotsX.Options(
"color" => cstr_stroke,
"draw opacity" => a_stroke,