A Rock, Paper, Scissors Table Plot In Python

Hi there. In this short post, I show how to generate a simple rock, paper, scissors table plot in Python. The code is not really long but it did take a while for me to find the right resources to help me put the code together.




  • https://s3.amazonaws.com/assets.datacamp.com/blog_assets/Python_Seaborn_Cheat_Sheet.pdf
  • https://stackoverflow.com/questions/33158075/custom-annotation-seaborn-heatmap
  • https://stackoverflow.com/questions/40734343/artificial-tick-labels-for-seaborn-heatmaps


A Basic Rock, Paper, Scissors Table Plot

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



Next, I create a list of outcome options, a two dimensional Numpy array of numbers and a two dimensional Numpy array of outcome labels. In the second list, a one represents a win, a zero is a draw and a negative one is a loss.



To start the plotting part, use fig, ax = plt.subplots(). Seaborn’s heatmap function is attached to the variable ax. To enable the labels in the heatmap, use the arguments annot = , xticklabels =  and yticklabels =   .

Plot labels can be added in with set_xlabel, set_ylabel and plt.title.



Leave a Reply