@@ -137,6 +137,23 @@ def test_boxplot(self):
137
137
else : # pragma: no cover
138
138
self .skipTest ('matplotlib not installed' )
139
139
140
+ def test_boxplot_with_passed_axes (self ):
141
+ # Test that can plot on a given matplotlib axes
142
+ if matplotlib_installed :
143
+ fig , axarr = plt .subplots (2 , 2 )
144
+ self .assertEqual (axarr [0 , 1 ].get_ylim (), (0 , 1 ))
145
+ plot = axelrod .Plot (self .test_result_set )
146
+ plot .boxplot (ax = axarr [0 , 1 ])
147
+ self .assertNotEqual (axarr [0 , 1 ].get_ylim (), (0 , 1 ))
148
+
149
+ # Plot on another axes with a title
150
+ plot .boxplot (title = "Test" , ax = axarr [1 , 0 ])
151
+ self .assertNotEqual (axarr [1 , 0 ].get_ylim (), (0 , 1 ))
152
+ self .assertEqual (axarr [1 , 0 ].get_title (), "Test" )
153
+
154
+ else : # pragma: no cover
155
+ self .skipTest ('matplotlib not installed' )
156
+
140
157
def test_boxplot_with_title (self ):
141
158
if matplotlib_installed :
142
159
plot = axelrod .Plot (self .test_result_set )
@@ -219,10 +236,11 @@ def test_payoff_with_title(self):
219
236
else : # pragma: no cover
220
237
self .skipTest ('matplotlib not installed' )
221
238
222
- def test_ecosystem (self ):
239
+ def test_stackplot (self ):
223
240
if matplotlib_installed :
224
241
eco = axelrod .Ecosystem (self .test_result_set )
225
242
eco .reproduce (100 )
243
+
226
244
plot = axelrod .Plot (self .test_result_set )
227
245
fig = plot .stackplot (eco )
228
246
self .assertIsInstance (fig , matplotlib .pyplot .Figure )
@@ -236,6 +254,28 @@ def test_ecosystem(self):
236
254
else : # pragma: no cover
237
255
self .skipTest ('matplotlib not installed' )
238
256
257
+ def test_stackplot_with_passed_axes (self ):
258
+ # Test that can plot on a given matplotlib axes
259
+ if matplotlib_installed :
260
+ eco = axelrod .Ecosystem (self .test_result_set )
261
+ eco .reproduce (100 )
262
+ plot = axelrod .Plot (self .test_result_set )
263
+
264
+ fig , axarr = plt .subplots (2 , 2 )
265
+ self .assertEqual (axarr [0 , 1 ].get_xlim (), (0 , 1 ))
266
+
267
+ plot .stackplot (eco , ax = axarr [0 , 1 ])
268
+ self .assertNotEqual (axarr [0 , 1 ].get_xlim (), (0 , 1 ))
269
+
270
+ # Plot on another axes with a title
271
+ plot .stackplot (eco ,title = "dummy title" , ax = axarr [1 , 0 ])
272
+ self .assertNotEqual (axarr [1 , 0 ].get_xlim (), (0 , 1 ))
273
+ self .assertEqual (axarr [1 , 0 ].get_title (), "dummy title" )
274
+
275
+ else : # pragma: no cover
276
+ self .skipTest ('matplotlib not installed' )
277
+
278
+
239
279
def test_all_plots (self ):
240
280
if matplotlib_installed :
241
281
plot = axelrod .Plot (self .test_result_set )
0 commit comments