Steam Visualisation with Matplotlib and Bokeh

I was inspired to look at the data offered by the Steam API after seeing that a friend of mine had played Rome: Total War for over 611 hours, far outweighing the 150 hours I put into Skyrim. I think it says something about my values and goals system that I view this figure with awe and regard it as something to aspire to.

Steam is a platform that allows you to buy video games (and movies), download them and play them on your computer and some mobile devices. Users can also add friends to play multiplayer games with.

By checking the playtime of each game I was able to get a figure for how many games a user owned and actually played. A play count variable for each user was incremented by 1 for every game with more than 0 minutes of play time and I can then print this off besides the total number of games owned:

BC 44 / 112
DD 93 / 207
BK 77 / 106
Maniacalbrain 47 / 72
PH 44 / 86
TD 24 / 37

User TD has played and owns the least amount of games but the largest total playtime (he of the 600+ hours in Rome). Myself, PH and TD have played just over half of the games we own while the others have played significantly less, a very common trend as I talked to people over the week. This is often thanks to buying a bundle of games because you want one of them and of course steam sales.

Using pandas I created a dataframe, each row of which was a game, its owner, the total time played and the users color as on the above pie chart. I only included games played for more than 0 minutes. I copied this dataframe and to the second one I added a row for the median value which was 208 minutes, the average playtime for each user and the overall average which was 1134 minutes. This creates a very large chart which you can find on the nbviewer, the top 10 of which is below.

My 150 hours on Skyrim just about manages to get me in at the bottom while at the top we can clearly see someone really like the Total War franchise.

Finally I created a chart in Bokeh for my own figures. Skyrim and Crusader Kings II are at the top with Caves of Qud at 7th place even though I have only owned it since the start of the month. I’m beginning to think I’m not as hardcore a gamer as I thought I was.

There are a number of reasons I did not use Bokeh for any of the above graphs. Firstly, it has no pie chart (it has a Donut.) and while this is an often maligned type of chart it does have its uses. Bokeh does not seem to be able to process strings with ":" in them which is why I had to remove them all in the game names to get my chart to show. If one had snuck into my top 10 what would have happened is neither the name nor the bar would have appeared. But mainly the segment chart I used for the horizontal bar chart does not seem to be able to process multiple occurrences of the same string. In the above Matplotlib chart my copy of Terraria, DD’s copy and BC’s copy are all plotted with our respective colors. In Bokeh after plotting the first Terraria bar it would then proceed to blank the rest. However, this was my first experience with Bokeh and I’m sure a more thorough look at the documentation would have helped. I used a segment chart instead of the actual bar chart because of the control it gave when fiddling around with the x and y axis ticks and labels (and also because it is what I found in the examples).

I used Bokeh completely in a project I was working on for the past week that will allow you to visualise your own Steam data. Click here to submit your own Steam profile URL to get a visualisation of your past two weeks on Steam and your all time figure for all games you have played (or check out my profile).

I really enjoyed working on this project and would love to hear any feedback or error reports. Post below, hit me up on Steam, though multiplayer depends on my crappy internet, or through any of the contact details in the about section.