def plotVectors(json, coincidence=0, name="", minTime=30, maxTime=1700, labels=False): delims = readDelims() macAddresses = {} json["packets"].apply(lambda row: addPacket(row, macAddresses), axis=1) sum = np.zeros(json["last"], dtype=np.int) for val in macAddresses.values(): diff = val[1] - val[0] if ((diff > minTime) and (diff < maxTime) and (val[2] >= coincidence)): sum[val[0]: val[1]] += 1 plot.xlabel('Seconds since start') plot.ylabel('Devices', color='b') plot.step(range(int(json["last"])), sum.tolist()) actual = [stop['actual'] for stop in delims] stopx = [stop['start'] for stop in delims] ax2 = plot.twinx() ax2.step(stopx, actual, 'r', where="post") (t1.set_color for t1 in ax2.get_yticklabels()) ax2.set_ylabel('Riders', color='r') plot.ylim(0, 30) plot.xlim(0, json["last"]) if(labels): for stop in delims: annotate(stop["code"], stop["start"], stop["actual"], 10, 10) makeWidePlot("bus", "vectors") plot.show()
def plotPacketHistogram(jason, cutoff=120): macAddresses = {} jason["packets"].apply(lambda row: addPacket(row, macAddresses), axis=1) packetAxis = [val[2] for val in macAddresses.values() if (val[0]+jason["last"]-val[1]) < cutoff] xmax = len(packetAxis) plot.xlim(0, xmax) plot.yscale('log') plot.bar(range(xmax), sorted(packetAxis), color="black", log=True) plot.xlabel("Unique MAC addresses present for the entire class period") plot.ylabel('Number of Packets seen for each MAC address') plot.title('April 7th, Classroom Packet Distribution') graphlib.makeWidePlot("class","packethist") plot.show()