Merge pull request #2351 from o01eg/fix-2350

Treat types without length as a single element
This commit is contained in:
Michael Krabbe Borregaard 2020-01-20 11:51:40 +01:00 committed by GitHub
commit 33d04c3e6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -591,7 +591,9 @@ annotations(sa::SeriesAnnotations) = sa
function process_annotation(sp::Subplot, xs, ys, labs, font = font()) function process_annotation(sp::Subplot, xs, ys, labs, font = font())
anns = [] anns = []
labs = makevec(labs) labs = makevec(labs)
for i in 1:max(length(xs), length(ys), length(labs)) xlength = length(methods(length, (typeof(xs),))) == 0 ? 1 : length(xs)
ylength = length(methods(length, (typeof(ys),))) == 0 ? 1 : length(ys)
for i in 1:max(xlength, ylength, length(labs))
x, y, lab = _cycle(xs, i), _cycle(ys, i), _cycle(labs, i) x, y, lab = _cycle(xs, i), _cycle(ys, i), _cycle(labs, i)
if lab == :auto if lab == :auto
alphabet = "abcdefghijklmnopqrstuvwxyz" alphabet = "abcdefghijklmnopqrstuvwxyz"

View File

@ -7,6 +7,7 @@ using FileIO
using Gtk using Gtk
using LibGit2 using LibGit2
using GeometryTypes using GeometryTypes
using Dates
include("test_pgfplotsx.jl") include("test_pgfplotsx.jl")
@ -67,6 +68,21 @@ img_tol = is_ci() ? 10e-2 : 10e-2
p = bar(randn(10)) p = bar(randn(10))
@test isa(p, Plots.Plot) == true @test isa(p, Plots.Plot) == true
@test isa(display(p), Nothing) == true @test isa(display(p), Nothing) == true
p = plot([1, 2], [3, 4])
annotate!(p, [(1.5, 3.2, Plots.text("Test", :red, :center))])
hline!(p, [3.1])
@test isa(p, Plots.Plot) == true
@test isa(display(p), Nothing) == true
p = plot([Dates.Date(2019, 1, 1), Dates.Date(2019, 2, 1)], [3, 4])
hline!(p, [3.1])
annotate!(p, [(Dates.Date(2019, 1, 15), 3.2, Plots.text("Test", :red, :center))])
@test isa(p, Plots.Plot) == true
@test isa(display(p), Nothing) == true
p = plot([Dates.Date(2019, 1, 1), Dates.Date(2019, 2, 1)], [3, 4])
annotate!(p, [(Dates.Date(2019, 1, 15), 3.2, Plots.text("Test", :red, :center))])
hline!(p, [3.1])
@test isa(p, Plots.Plot) == true
@test isa(display(p), Nothing) == true
end end
end end