A first graph with Matplotlib in Python
Archive - Originally posted on "The Horse's Mouth" - 2015-02-22 12:55:43 - Graham Ellis"A picture paints a thousand words" and in Python, you can paint a graph based picture using matplotlib. Matplotlib is massive - a huge range of facilities, a 2000 page manual if you print it out - yet if you know where to start "hello graphing world" is straightforward.
Taking my previous blog example - [here], where I analysed 1 Gbyte of data and created a Json file with summary details, I've now gone on and added a graph showing the usage on a day by day basis of one of the hosts on our server. Extra code:
import matplotlib.pyplot as plt
hostToGraph = u"www.firstgreatwestern.info"
plotData = []
for row in daily:
plotData.append(row.get(hostToGraph,0))
plt.plot(plotData)
plt.ylabel('Requests per day')
plt.xlabel('Days')
plt.title("Accesses from " + hostToGraph)
plt.show()
And the output:

Complete code [here]
My delegates for next week have asked me to show them how to get to Matplotlib from Python. If it turns out they want rather more, you'll see lote more examples appearing here in a day or two. My background is very much computer graphics and I will welcome the opportunity!