A Rock, Paper, Scissors, Lizard, Spock Table Plot In Python

Hi there. This is a follow up to the page that is focused on generating a rock, paper, scissors table plot. In this page, the lizard and the spock is added on top of rock, paper, scissors.


Setting Up The Table Plot


To start, import the pandas, seaborn, numpy and matplotlib’s pyplot modules into Python.



The first Python list of three is a list of options. There are five options that the player can choose. These five are:

  1. Rock
  2. Paper
  3. Scissors
  4. Lizard
  5. Spock


The large image below shows which option beats what.


Source: http://wordpress.morningside.edu/cdl001/files/2010/09/RockPaperScissorsLizardSpock.jpg



A win for the payer is a 1, a draw is a 0 and a loss for the player is a -1. This two-dimensional Numpy array is for different colours in the upcoming heatmap. A second two-dimensional Numpy array is for the labels which would be easy of the viewer to read.


Plotting The Outcome Table

The main part for generating the table plot is Seaborn’s heatmap() function. To enable the labels, use annot = , xticklabels = and yticklabels = . Labels and a title is added.




Even though the table plot looks scary it is easy to follow. The bottom label is for the option that you have chosen and the left label is for what your opponent has chosen.




  • https://stackoverflow.com/questions/33158075/custom-annotation-seaborn-heatmap
  • https://stackoverflow.com/questions/40734343/artificial-tick-labels-for-seaborn-heatmaps

Leave a Reply