# Grid Running – Part Ia

As a post-script to last week’s post, here’s a snippet of Python code that uses the wonderful matplotlib to display a given frame of Timepix data. It takes the Comma Separated Value (CSV) file generated by the frame reader and plots a “pixel” at each (x, y) with a colour corresponding to the number of counts measured by that pixel. I’ve added the Python code to the github repository as display.py, but it’s also included below so you can use it however you like. I’ve been having a lot of fun with IPython and the IPython notebook (which you can find out how to install on your own system here) to do all this on a web browser (screenshot above). But here’s the source code anyway:

```###############################################################################
#              CERN@school: A very simple Python frame display                #
###############################################################################
# Author: T. Whyntie - t.whyntie [at] qmul.ac.uk                              #
# Date:   April 2013                                                          #
###############################################################################
#!/bin/env python

# Import what we need from numpy and matplotlib.
from matplotlib import pyplot
from matplotlib.patches import Rectangle

# Open the data file - specify the actual filename between the quotes.
datafile = open("dataout0.csv", "r")

# Get the X, Y and C values from the data file.
X, Y, C = loadtxt(datafile, delimiter=",", unpack=True)

# Set up the plot area for the frame data.
pyplot.figure().add_subplot(111, aspect='equal') # ensure equal aspect ratio.
pyplot.xlim(0,256)                               # x limits.
pyplot.ylim(0,256)                               # y limits.
pyplot.gca().patch.set_facecolor((0,0,0))        # Black background.

# Select the "hot" colour map for the pixel counts.
cmap = pyplot.cm.hot

# Loop over the pixels extracted from the data file and draw a "pixel"
# in the plot area.
for x, y, c in zip(X, Y, C):