improved fillrange
This commit is contained in:
parent
0d2ccfddfb
commit
be5cd7de2e
@ -210,8 +210,8 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
else
|
else
|
||||||
iter_segments(series)
|
iter_segments(series)
|
||||||
end
|
end
|
||||||
segment_opt = PGFPlotsX.Options()
|
|
||||||
for (i, rng) in enumerate(segments)
|
for (i, rng) in enumerate(segments)
|
||||||
|
segment_opt = PGFPlotsX.Options()
|
||||||
segment_opt = merge( segment_opt, pgfx_linestyle(opt, i) )
|
segment_opt = merge( segment_opt, pgfx_linestyle(opt, i) )
|
||||||
if opt[:markershape] != :none
|
if opt[:markershape] != :none
|
||||||
marker = opt[:markershape]
|
marker = opt[:markershape]
|
||||||
@ -235,15 +235,28 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
segment_opt = merge( segment_opt, pgfx_marker(opt, i) )
|
segment_opt = merge( segment_opt, pgfx_marker(opt, i) )
|
||||||
end
|
end
|
||||||
if st == :shape ||
|
if st == :shape ||
|
||||||
(series[:fillrange] !== nothing && !isfilledcontour(series)) &&
|
isfilledcontour(series) ||
|
||||||
series[:ribbon] === nothing
|
series[:ribbon] !== nothing
|
||||||
segment_opt = merge( segment_opt, pgfx_fillstyle(opt, i) )
|
segment_opt = merge( segment_opt, pgfx_fillstyle(opt, i) )
|
||||||
end
|
end
|
||||||
|
# add fillrange
|
||||||
|
if series[:fillrange] !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing
|
||||||
|
pgfx_fillrange_series!( axis, series, series_func, i, _cycle(series[:fillrange], rng), rng)
|
||||||
|
# add to legend?
|
||||||
|
if i == 1 && opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
|
||||||
|
io = IOBuffer()
|
||||||
|
PGFPlotsX.print_tex(io, pgfx_fillstyle(opt, i))
|
||||||
|
style = strip(String(take!(io)),['[',']', ' '])
|
||||||
|
push!( segment_opt, "legend image code/.code" => """{
|
||||||
|
\\draw[##1,/tikz/.cd, $style] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
|
||||||
|
}""" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# series
|
||||||
coordinates = pgfx_series_coordinates!( sp, series, segment_opt, opt, rng )
|
coordinates = pgfx_series_coordinates!( sp, series, segment_opt, opt, rng )
|
||||||
segment_plot = series_func(
|
segment_plot = series_func(
|
||||||
merge(series_opt, segment_opt),
|
merge(series_opt, segment_opt),
|
||||||
coordinates,
|
coordinates,
|
||||||
(series[:fillrange] !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing) ? "\\closedcycle" : "{}"
|
|
||||||
)
|
)
|
||||||
push!(axis, segment_plot)
|
push!(axis, segment_plot)
|
||||||
# add ribbons?
|
# add ribbons?
|
||||||
@ -253,7 +266,8 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
end
|
end
|
||||||
# add to legend?
|
# add to legend?
|
||||||
if i == 1 && opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
|
if i == 1 && opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
|
||||||
push!( axis, PGFPlotsX.LegendEntry(opt[:label]) )
|
legend = PGFPlotsX.LegendEntry(PGFPlotsX.Options(), opt[:label], true)
|
||||||
|
push!( axis, legend )
|
||||||
end
|
end
|
||||||
# add series annotations
|
# add series annotations
|
||||||
anns = series[:series_annotations]
|
anns = series[:series_annotations]
|
||||||
@ -634,6 +648,35 @@ function pgfx_add_ribbons!( axis, series, segment_plot, series_func, series_inde
|
|||||||
))
|
))
|
||||||
return axis
|
return axis
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function pgfx_fillrange_series!(axis, series, series_func, i, fillrange, rng)
|
||||||
|
fillrange_opt = PGFPlotsX.Options(
|
||||||
|
"line width" => "0",
|
||||||
|
"draw opacity" => "0",
|
||||||
|
)
|
||||||
|
fillrange_opt = merge( fillrange_opt, pgfx_fillstyle(series, i) )
|
||||||
|
fillrange_opt = merge( fillrange_opt, pgfx_marker(series, i) )
|
||||||
|
push!( fillrange_opt, "forget plot" => nothing )
|
||||||
|
opt = series.plotattributes
|
||||||
|
args = is3d(series) ? (opt[:x][rng], opt[:y][rng], opt[:z][rng]) : (opt[:x][rng], opt[:y][rng])
|
||||||
|
push!(axis, PGFPlotsX.PlotInc(fillrange_opt, pgfx_fillrange_args(fillrange, args...)))
|
||||||
|
return axis
|
||||||
|
end
|
||||||
|
|
||||||
|
function pgfx_fillrange_args(fillrange, x, y)
|
||||||
|
n = length(x)
|
||||||
|
x_fill = [x; x[n:-1:1]; x[1]]
|
||||||
|
y_fill = [y; _cycle(fillrange, n:-1:1); y[1]]
|
||||||
|
return PGFPlotsX.Coordinates(x_fill, y_fill)
|
||||||
|
end
|
||||||
|
|
||||||
|
function pgfx_fillrange_args(fillrange, x, y, z)
|
||||||
|
n = length(x)
|
||||||
|
x_fill = [x; x[n:-1:1]; x[1]]
|
||||||
|
y_fill = [y; y[n:-1:1]; x[1]]
|
||||||
|
z_fill = [z; _cycle(fillrange, n:-1:1); z[1]]
|
||||||
|
return PGFPlotsX.Coordiantes(x_fill, y_fill, z_fill)
|
||||||
|
end
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||||
axis = sp[Symbol(letter,:axis)]
|
axis = sp[Symbol(letter,:axis)]
|
||||||
|
|||||||
@ -113,7 +113,6 @@ end
|
|||||||
x + y
|
x + y
|
||||||
end), color=:bluesreds, legend=false)
|
end), color=:bluesreds, legend=false)
|
||||||
plot(p1, p2)
|
plot(p1, p2)
|
||||||
# TODO: questionable tiling
|
|
||||||
end # testset
|
end # testset
|
||||||
@testset "Framestyles" begin
|
@testset "Framestyles" begin
|
||||||
scatter(fill(randn(10), 6), fill(randn(10), 6), framestyle=[:box :semi :origin :zerolines :grid :none], title=[":box" ":semi" ":origin" ":zerolines" ":grid" ":none"], color=permutedims(1:6), layout=6, label="", markerstrokewidth=0, ticks=-2:2)
|
scatter(fill(randn(10), 6), fill(randn(10), 6), framestyle=[:box :semi :origin :zerolines :grid :none], title=[":box" ":semi" ":origin" ":zerolines" ":grid" ":none"], color=permutedims(1:6), layout=6, label="", markerstrokewidth=0, ticks=-2:2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user