plot


In [216]:
import numpy as np
import pandas as pd
import pylab as pl
import matplotlib.pyplot as plt
import hmac
import hashlib
import ipaddress


%matplotlib inline

df = pd.read_csv('tmp/session_.csv')

df['SrcPort'] = pd.to_numeric(df['SrcPort'])
df['DstPort'] = pd.to_numeric(df['DstPort'])


pl.figure(figsize=(12, 6))
p = df.groupby('DstPort')['DstPort'].count().plot()
p.set_xlim(0,65535)
p.set_xticks([0,10000,20000,30000,40000,50000,60000,65535])


Out[216]:
[<matplotlib.axis.XTick at 0x12c29a4d0>,
 <matplotlib.axis.XTick at 0x19cba54d0>,
 <matplotlib.axis.XTick at 0x195e26ad0>,
 <matplotlib.axis.XTick at 0x195e2d190>,
 <matplotlib.axis.XTick at 0x195e2d8d0>,
 <matplotlib.axis.XTick at 0x195e0e050>,
 <matplotlib.axis.XTick at 0x195e0e790>,
 <matplotlib.axis.XTick at 0x195e0eed0>]

In [207]:
pl.figure(figsize=(12, 6))
df.groupby('DstPort')['DstPort'].count().order(ascending=False)[:20].plot.bar()


/Users/mhaya/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ipykernel/__main__.py:2: FutureWarning: order is deprecated, use sort_values(...)
  from ipykernel import kernelapp as app
Out[207]:
<matplotlib.axes._subplots.AxesSubplot at 0x197edbfd0>

In [217]:
from matplotlib.ticker import *
tmp = df[df.DstPort < 1024]
pl.figure(figsize=(12, 6))
p = tmp.groupby('DstPort')['DstPort'].count().plot.bar()



In [218]:
pl.figure(figsize=(12, 6))
p=df.groupby('SrcPort')['SrcPort'].count().plot()
p.set_xlim(0,65535)
p.set_xticks([0,10000,20000,30000,40000,50000,60000,65535])


Out[218]:
[<matplotlib.axis.XTick at 0x19b6bce10>,
 <matplotlib.axis.XTick at 0x19b531510>,
 <matplotlib.axis.XTick at 0x16dc7f510>,
 <matplotlib.axis.XTick at 0x16dc7fb90>,
 <matplotlib.axis.XTick at 0x19955f310>,
 <matplotlib.axis.XTick at 0x19955fa50>,
 <matplotlib.axis.XTick at 0x1995671d0>,
 <matplotlib.axis.XTick at 0x199567910>]

In [203]:
pl.figure(figsize=(12, 6))
df.groupby('SrcPort')['SrcPort'].count().order(ascending=False)[:20].plot.bar()


/Users/mhaya/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ipykernel/__main__.py:2: FutureWarning: order is deprecated, use sort_values(...)
  from ipykernel import kernelapp as app
Out[203]:
<matplotlib.axes._subplots.AxesSubplot at 0x197cefbd0>

In [219]:
p = df.plot.scatter(x='SrcPort',y='DstPort',figsize=(12, 6))
p.set_xlim(0,65535)
p.set_xticks([0,10000,20000,30000,40000,50000,60000,65535])
p.set_ylim(0,65535)
p.set_yticks([0,10000,20000,30000,40000,50000,60000,65535])


Out[219]:
[<matplotlib.axis.YTick at 0x1995861d0>,
 <matplotlib.axis.YTick at 0x19957fc90>,
 <matplotlib.axis.YTick at 0x19aab8c50>,
 <matplotlib.axis.YTick at 0x124e0f1d0>,
 <matplotlib.axis.YTick at 0x19aab1450>,
 <matplotlib.axis.YTick at 0x199537f90>,
 <matplotlib.axis.YTick at 0x124e0f750>,
 <matplotlib.axis.YTick at 0x124e0fe90>]