Commit 571956e7 authored by Mario Hock's avatar Mario Hock
Browse files

Twin plot (proof-of-concept)

parent 87cccfaf
......@@ -4,7 +4,7 @@
import sys
import matplotlib.pyplot as plt
from cnl_library import CNLParser
from cnl_library import CNLParser, calc_ema
def append_twice(base_list, extend_list):
......@@ -40,9 +40,11 @@ if __name__ == "__main__":
## Prepare data for matplotlib
#nics = cnl_file.get_nics()
nics = ("eth1", "eth2")
net_cols = list()
nic_fields = [".send", ".receive"]
for nic_name in cnl_file.get_nics():
for nic_name in nics:
for nic_field in nic_fields:
net_cols.append( nic_name + nic_field )
......@@ -50,16 +52,32 @@ if __name__ == "__main__":
cols = cnl_file.get_csv_columns()
x_values = cols["end"]
print( cols )
#print( cols ) ## XXX
## Plot with matplotlib.
#for col_name in net_cols:
# Twin plot
# (see http://matplotlib.org/examples/api/two_scales.html)
fig, ax1 = plt.subplots()
plt.ylim(0,10**10)
ax1.set_ylabel('Throughput (Bit/s)')
for col_name in net_cols:
ax1.plot(x_values , cols[col_name], label=col_name)
ax1.plot(x_values , calc_ema(cols[col_name], 0.2), label=col_name+" (ema)")
ax2 = ax1.twinx()
plt.ylim(0,100)
ax2.set_ylabel('CPU util (%)')
for col_name in cpu_cols:
plt.plot(x_values , cols[col_name], label=col_name)
ax2.plot(x_values , cols[col_name], label=col_name)
#ax2.plot(x_values , calc_ema(cols[col_name], 0.2), label=col_name+" (ema)")
## TODO twinx: http://matplotlib.org/examples/api/two_scales.html
## TODO twinx:
plt.legend()
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment