Skip to content

Instantly share code, notes, and snippets.

@keewon keewon/graph.py
Last active Aug 29, 2015

Embed
What would you like to do?
Graph with Python
import matplotlib.pyplot as plt
# load data
qos0 = open('qos0.txt').readlines()
qos1 = open('qos1.txt').readlines()
qos2 = open('qos2.txt').readlines()
qos0 = qos0[1:]
qos1 = qos1[1:]
qos2 = qos2[1:]
x0 = []
y0 = []
x1 = []
y1 = []
x2 = []
y2 = []
# time,connected,subscribed,published_per_sec,published,puback,received,response
for l in qos0:
items = l.split(',')
x0.append(items[3])
y0.append(items[7])
for l in qos1:
items = l.split(',')
x1.append(items[3])
y1.append(items[7])
for l in qos2:
items = l.split(',')
x2.append(items[3])
y2.append(items[7])
# plot
plt.title('MQTT performance on my Macbook Air')
plt.xlabel('publishes per seconds')
plt.ylabel('response time')
plt.plot(x0, y0, 'r', label='qos0')
plt.hold(True)
plt.plot(x1, y1, 'g', label='qos1')
plt.hold(True)
plt.plot(x2, y2, 'b', label='qos2')
plt.legend(loc='upper left')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.