@@ -7,7 +7,7 @@ xseries(pl, idx = length(pl.series_list)) = pl.series_list[idx].plotattributes[:
7
7
yseries (pl, idx = length (pl. series_list)) = pl. series_list[idx]. plotattributes[:y ]
8
8
zseries (pl, idx = length (pl. series_list)) = pl. series_list[idx]. plotattributes[:z ]
9
9
10
- testfile = tempname () * " .png"
10
+ forcedraw (pl) = savefig (pl, tempname () * " .png" )
11
11
12
12
macro isplot (ex) # @isplot macro to streamline tests
13
13
:(@test $ (esc (ex)) isa Plot)
41
41
@testset " yunit" begin
42
42
@test yguide (plot (y, yunit = cm)) == " cm"
43
43
@test yseries (plot (y, yunit = cm)) ≈ ustrip .(cm, y)
44
+ @test getaxisunit (plot (y, yunit = cm). subplots[1 ][:yaxis ]) == cm
44
45
end
45
46
46
47
@testset " ylims" begin # Using all(lims .≈ lims) because of uncontrolled type conversions?
52
53
@test_throws DimensionError begin
53
54
pl = plot (y)
54
55
plot! (pl; ylims = (- 1 s, 5 s))
55
- savefig (pl, testfile )
56
+ forcedraw (pl)
56
57
end
57
58
end
58
59
62
63
pl = plot (y; ylims = encompassing_ylims, yticks = (1 : 5 )m)
63
64
@test compare_yticks (pl, 1 : 5 )
64
65
pl = plot (y; ylims = encompassing_ylims, yticks = [1 cm, 3 cm])
65
- savefig (pl, testfile )
66
+ forcedraw (pl)
66
67
@test compare_yticks (pl, [0.01 , 0.03 ])
67
68
pl = plot! (; ylims = encompassing_ylims, yticks = [- 1 cm, 4 cm])
68
- savefig (pl, testfile )
69
+ forcedraw (pl)
69
70
@test compare_yticks (pl, [- 0.01 , 0.04 ])
70
71
@test_throws DimensionError begin
71
72
pl = plot (y)
72
73
plot! (pl; yticks = (1 : 5 )s)
73
- savefig (pl, testfile )
74
+ forcedraw (pl)
74
75
end
75
76
end
76
77
@@ -337,19 +338,18 @@ end
337
338
338
339
@testset " Aspect ratio" begin
339
340
pl = plot ((1 : 10 )u " m" , (1 : 10 )u " dm" ; aspect_ratio = :equal )
340
- savefig (pl, testfile) # Force a render, to make it evaluate aspect ratio
341
+ forcedraw (pl)
341
342
@test abs (- (ylims (pl)... )) > 50
342
343
plot! (pl, (3 : 4 )u " m" , (4 : 5 )u " m" )
343
344
@test first (pl. subplots)[:aspect_ratio ] == 1 // 10 # This is what "equal" means when yunit==xunit/10
344
345
pl = plot ((1 : 10 )u " m" , (1 : 10 )u " dm" ; aspect_ratio = 2 )
345
- savefig (pl, testfile )
346
+ forcedraw (pl)
346
347
@test 25 < abs (- (ylims (pl)... )) < 50
347
348
pl = plot ((1 : 10 )u " m" , (1 : 10 )u " s" ; aspect_ratio = 1 u " m/s" )
348
- savefig (pl, testfile )
349
+ forcedraw (pl)
349
350
@test 7.5 < abs (- (ylims (pl)... )) < 12.5
350
- @test_throws DimensionError savefig (
351
+ @test_throws DimensionError forcedraw (
351
352
plot ((1 : 10 )u " m" , (1 : 10 )u " s" ; aspect_ratio = :equal ),
352
- testfile,
353
353
)
354
354
end
355
355
0 commit comments