add tests for series_annotations in layouts
This commit is contained in:
parent
7ca32b5edd
commit
6e00be5840
@ -1,4 +1,4 @@
|
||||
using Plots: guidefont
|
||||
using Plots: guidefont, series_annotations
|
||||
import ImageMagick
|
||||
using VisualRegressionTests
|
||||
using Plots
|
||||
|
||||
@ -84,9 +84,17 @@ end
|
||||
|
||||
@testset "Fonts" begin
|
||||
@testset "Scaling" begin
|
||||
sizesToCheck = [:titlefontsize, :legendfontsize, :legendtitlefontsize,
|
||||
:xtickfontsize, :ytickfontsize, :ztickfontsize,
|
||||
:xguidefontsize, :yguidefontsize, :zguidefontsize,]
|
||||
sizesToCheck = [
|
||||
:titlefontsize,
|
||||
:legendfontsize,
|
||||
:legendtitlefontsize,
|
||||
:xtickfontsize,
|
||||
:ytickfontsize,
|
||||
:ztickfontsize,
|
||||
:xguidefontsize,
|
||||
:yguidefontsize,
|
||||
:zguidefontsize,
|
||||
]
|
||||
# get inital font sizes
|
||||
initialSizes = [Plots.default(s) for s in sizesToCheck]
|
||||
|
||||
@ -110,18 +118,34 @@ end
|
||||
@testset "Series Annotations" begin
|
||||
square = Shape([(0, 0), (1, 0), (1, 1), (0, 1)])
|
||||
@test_logs (:warn, "Unused SeriesAnnotations arg: triangle (Symbol)") begin
|
||||
p = plot([1,2,3],
|
||||
series_annotations=(["a"],
|
||||
p = plot(
|
||||
[1, 2, 3],
|
||||
series_annotations = (
|
||||
["a"],
|
||||
2, # pass a scale factor
|
||||
(1, 4), # pass two scale factors (overwrites first one)
|
||||
square, # pass a shape
|
||||
font(:courier), # pass an annotation font
|
||||
:triangle # pass an incorrect argument
|
||||
))
|
||||
:triangle, # pass an incorrect argument
|
||||
),
|
||||
)
|
||||
sa = p.series_list[1].plotattributes[:series_annotations]
|
||||
@test sa.strs == ["a"]
|
||||
@test sa.font.family == "courier"
|
||||
@test sa.baseshape == square
|
||||
@test sa.scalefactor == (1, 4)
|
||||
end
|
||||
spl = scatter(
|
||||
4.53 .* [1/1 1/2 1/3 1/4 1/5],
|
||||
[0 0 0 0 0],
|
||||
layout = (5, 1),
|
||||
ylims = (-1.1, 1.1),
|
||||
xlims = (0, 5),
|
||||
series_annotations = ["1/1" "1/2" "1/3" "1/4" "1/5"],
|
||||
)
|
||||
@test spl.series_list[1].plotattrubtes[:series_annotations].strs == ["1/1"]
|
||||
@test spl.series_list[2].plotattrubtes[:series_annotations].strs == ["1/2"]
|
||||
@test spl.series_list[3].plotattrubtes[:series_annotations].strs == ["1/3"]
|
||||
@test spl.series_list[4].plotattrubtes[:series_annotations].strs == ["1/4"]
|
||||
@test spl.series_list[5].plotattrubtes[:series_annotations].strs == ["1/5"]
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user