Skip to content

Commit a807fa5

Browse files
committed
Update docs with Win plots
1 parent b3258ca commit a807fa5

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

axelrod/plot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def winplot(self):
8181
return None
8282

8383
wins, ranked_names = self._winplot_dataset
84+
maximum = max(max(w) for w in wins)
8485

8586
figure = plt.figure()
8687
plt.boxplot(wins)
@@ -90,6 +91,7 @@ def winplot(self):
9091
rotation=90)
9192
plt.tick_params(axis='both', which='both', labelsize=7)
9293
plt.title(self._winplot_title)
94+
plt.ylim(-0.5, 0.5 + maximum)
9395
return figure
9496

9597
def payoff(self):

docs/usage.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,27 @@ The resulting wins matrix is::
303303

304304
which shows, for example, that Cooperator had 0 wins, Defector won 8 times in each repetition and Random won 4 times in the first repetition and twice in the second.
305305

306+
For any tournament, a plot of the distribution of wins is created, much like the
307+
plot for the distribution of mean scores. For the demo strategies we create the
308+
plot as follows::
309+
310+
import axelrod
311+
strategies = [s() for s in axelrod.demo_strategies]
312+
tournament = axelrod.Tournament(strategies, game=Game(30, 0, 50, 10))
313+
results = tournament.play()
314+
plot = axelrod.Plot(results)
315+
p = plot.winplot()
316+
p.show()
317+
318+
This produces:
319+
320+
.. image:: _static/usage/demo_strategies_winplot.svg
321+
:width: 50%
322+
:align: center
323+
324+
In this case most of the strategies are deterministic, so there is not much
325+
variation in the distributions. See below for a more complex example.
326+
306327
Noisy Tournaments
307328
^^^^^^^^^^^^^^^^^
308329

@@ -365,6 +386,25 @@ and accordingly to the ranking of strategies overall:
365386
| |boxplot_no_noise| | |boxplot_5_noise| |
366387
+--------------------+-------------------+
367388

389+
as well as the distributions of wins:
390+
391+
and accordingly to the ranking of strategies overall:
392+
393+
.. |winplot_no_noise| image:: http://axelrod-python.github.io/tournament/assets/strategies_winplot.svg
394+
:width: 75%
395+
:align: middle
396+
:alt: Strategy performance without noise
397+
398+
.. |winplot_5_noise| image:: http://axelrod-python.github.io/tournament/assets/strategies_winplot_noise_5.svg
399+
:width: 75%
400+
:align: middle
401+
:alt: Strategy performance with 5% noise
402+
403+
+--------------------+-------------------+
404+
| |winplot_no_noise| | |winplot_5_noise| |
405+
+--------------------+-------------------+
406+
407+
368408
To run a noisy tournament, just use the keyword argument `noise` when
369409
creating tournaments. Both `run_axelrod` and the utility function
370410
`run_tournaments` accept and passthrough the noise argument. To run the
@@ -528,6 +568,13 @@ The results from the tournament itself (ordered by median score):
528568
:width: 50%
529569
:align: center
530570

571+
The distributions of head-to-head wins for each strategy:
572+
573+
.. image:: http://axelrod-python.github.io/tournament/assets/strategies_winplot.svg
574+
:width: 50%
575+
:align: center
576+
577+
531578
The payoff matrix from that tournament:
532579

533580
.. image:: http://axelrod-python.github.io/tournament/assets/strategies_payoff.svg

0 commit comments

Comments
 (0)