fix legends for arrows (#4161)
* fix legends for arrows * Apply suggestions from code review [skip ci] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * raise tolerance on windows * Update test/runtests.jl [skip ci] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
0f4a0c7154
commit
65ab68c3b5
@ -403,6 +403,9 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o
|
||||
),
|
||||
),
|
||||
)
|
||||
if opt[:label] == ""
|
||||
push!(arrow_opt, "forget plot" => nothing)
|
||||
end
|
||||
if arrow.side == :head
|
||||
x_arrow = opt[:x][rng][(end - 1):end]
|
||||
y_arrow = opt[:y][rng][(end - 1):end]
|
||||
@ -426,6 +429,7 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o
|
||||
:v => [y_arrow[i] - y_arrow[i - 1] for i in 2:2:lastindex(y_arrow)],
|
||||
])
|
||||
arrow_plot = series_func(merge(series_opt, arrow_opt), coordinates)
|
||||
push!(series_opt, "forget plot" => nothing)
|
||||
push!(axis, arrow_plot)
|
||||
coordinates = PGFPlotsX.Table(x_path, y_path)
|
||||
segment_plot = series_func(merge(series_opt, segment_opt), coordinates)
|
||||
|
||||
@ -363,7 +363,10 @@ Random.seed!(PLOTS_SEED)
|
||||
default(show = false, reuse = true) # don't actually show the plots
|
||||
|
||||
is_ci() = get(ENV, "CI", "false") == "true"
|
||||
const PLOTS_IMG_TOL = parse(Float64, get(ENV, "PLOTS_IMG_TOL", is_ci() ? "1e-4" : "1e-5"))
|
||||
const PLOTS_IMG_TOL = parse(
|
||||
Float64,
|
||||
get(ENV, "PLOTS_IMG_TOL", is_ci() ? Sys.iswindows() ? "2e-4" : "1e-4" : "1e-5"),
|
||||
)
|
||||
|
||||
## Uncomment the following lines to update reference images for different backends
|
||||
|
||||
|
||||
@ -21,16 +21,19 @@ end
|
||||
@test !haskey(axis.contents[1].options.dict, "fill")
|
||||
|
||||
@testset "Legends" begin
|
||||
legends_plot = plot(rand(5, 2), lab = ["1" ""])
|
||||
legends_plot = plot(rand(5, 2), lab = ["1" ""], arrow = true)
|
||||
scatter!(legends_plot, rand(5))
|
||||
Plots._update_plot_object(legends_plot)
|
||||
axis_contents = Plots.pgfx_axes(legends_plot.o)[1].contents
|
||||
leg_entries = filter(x -> x isa PGFPlotsX.LegendEntry, axis_contents)
|
||||
series = filter(x -> x isa PGFPlotsX.Plot, axis_contents)
|
||||
@test length(leg_entries) == 2
|
||||
@test length(series) == 5
|
||||
@test !haskey(series[1].options.dict, "forget plot")
|
||||
@test haskey(series[2].options.dict, "forget plot")
|
||||
@test !haskey(series[3].options.dict, "forget plot")
|
||||
@test haskey(series[3].options.dict, "forget plot")
|
||||
@test haskey(series[4].options.dict, "forget plot")
|
||||
@test !haskey(series[5].options.dict, "forget plot")
|
||||
end # testset
|
||||
|
||||
@testset "3D docs example" begin
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user