Skip to content

Instantly share code, notes, and snippets.

@csujedihy
Created April 7, 2018 00:44
Show Gist options
  • Save csujedihy/d3ed3f73f84e3032537e8698d9ca5642 to your computer and use it in GitHub Desktop.
Save csujedihy/d3ed3f73f84e3032537e8698d9ca5642 to your computer and use it in GitHub Desktop.
cwndplot.py
import matplotlib.pyplot as plt
import numpy
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('input', type=str, help='data file from netput')
parser.add_argument('-o', '--out', type=str, help='Output the plot to a PDF file')
args = parser.parse_args()
myArgs = (vars(args))
dataFilePath = myArgs["input"]
outputPath = myArgs["out"]
dataFile = numpy.loadtxt(dataFilePath, skiprows=1)
cols = dataFile[:, [0,3]].transpose()
times = [time/float(1000000) for time in cols[0]]
cwnds = cols[1]
plt.plot(times, cwnds)
plt.title("Cwnd vs Time")
plt.xlabel('Time (s)')
plt.ylabel('Cwnd (byte)')
plt.ylim(ymin=0)
plt.xlim(xmin=0)
plt.grid(True)
if outputPath:
plt.savefig(outputPath, bbox_inches='tight')
plt.close()
else:
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment