from scapy.all import *
import plotly
from datetime import datetime
import pandas as pd

#Read the packets from file

packets=rdpcap('mypcap.pcap')

#lists to hold packetinfo

pktBytes=[]
pktTimes=[]

#Read each packet and append to the lists

for pkt in packets:
	


# convert list to series
bytes=pd.Series(pktBytes).astype(int)
times=pd.to_datetime(pd.Series(pktTimes).astype(str), errors='coerce')

#Create the dateframe
df=pd.DataFrame({"Bytes": bytes, "Times":times})

#Set the date to a timestamp
df=df.set_index('Times')

df2=df.resample('2S').sum()
print(df2)

#Create the graph

plotly.offline.plot({
	"data":[plotly.graph_objs.Scatter(x=df2.index, y=df2['Bytes'])],
	"layout":plotly.graph_objs.Layout(title="Bytes over Time ",
	xaxis=dict(title="Time"),
	yaxis=dict(title="Bytes"))})

Output
if IP in pkt:
		try:
			pktBytes.append(pkt[IP].len)
			pktTime=datetime.fromtimestamp(pkt.time)
			pktTimes.append(pktTime.strftime("%Y-%m-%d %H:%M:%S.%f"))
		except:
			pass