@@ -4,7 +4,7 @@ using PyPlot, PyCall
44using Compat
55using Compat. Test
66
7- VERSION >= v " 0.7.0 " && using Base64
7+ Compat . @info ( " PyPlot is using Matplotlib $(PyPlot . version) with Python $(PyCall . pyversion) " )
88
99plot (1 : 5 , 2 : 6 , " ro-" )
1010
@@ -14,23 +14,28 @@ line = gca()[:lines][1]
1414
1515fig = gcf ()
1616@test isa (fig, PyPlot. Figure)
17- @test fig[:get_size_inches ]() ≈ [6.4 , 4.8 ]
18-
19- s = stringmime (" application/postscript" , fig);
20- m = match (r" %%BoundingBox: *([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+)" , s)
21- @test m != = nothing
22- boundingbox = map (s -> parse (Int, s), m. captures)
23- Compat. @info (" got plot bounding box " , boundingbox)
24- @test all ([300 , 200 ] .< boundingbox[3 : 4 ] - boundingbox[1 : 2 ] .< [450 ,350 ])
25-
26- c = get_cmap (" viridis" )
17+ if PyPlot. version >= v " 2"
18+ @test fig[:get_size_inches ]() ≈ [6.4 , 4.8 ]
19+ else # matplotlib 1.3
20+ @test fig[:get_size_inches ]() ≈ [8 , 6 ]
21+ end
22+
23+ # with Matplotlib 1.3, I get "UserWarning: bbox_inches option for ps backend is not implemented yet"
24+ if PyPlot. version >= v " 2"
25+ s = sprint (show, " application/postscript" , fig);
26+ m = match (r" %%BoundingBox: *([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+)" , s)
27+ @test m != = nothing
28+ boundingbox = map (s -> parse (Int, s), m. captures)
29+ Compat. @info (" got plot bounding box " , boundingbox)
30+ @test all ([300 , 200 ] .< boundingbox[3 : 4 ] - boundingbox[1 : 2 ] .< [450 ,350 ])
31+ end
32+
33+ c = get_cmap (" RdBu" )
2734a = 0.0 : 0.25 : 1.0
28-
29-
3035rgba = pycall (pycall (PyPlot. ScalarMappable, PyObject, cmap= c,
3136 norm= PyPlot. Normalize01)[" to_rgba" ], PyArray, a)
32- @test rgba ≈ [ 0.267004 0.004874 0.329415 1.0
33- 0.229739 0.322361 0.545706 1.0
34- 0.127568 0.566949 0.550556 1.0
35- 0.369214 0.788888 0.382914 1.0
36- 0.993248 0.906157 0.143936 1.0 ]
37+ @test rgba ≈ [ 0.403921568627451 0.0 0.12156862745098039 1.0
38+ 0.8991926182237601 0.5144175317185697 0.4079200307574009 1.0
39+ 0.9657054978854287 0.9672433679354094 0.9680891964628989 1.0
40+ 0.4085351787773935 0.6687427912341408 0.8145328719723184 1.0
41+ 0.0196078431372549 0.18823529411764706 0.3803921568627451 1.0 ]
0 commit comments