- # Add None to the lists with missing data
- max_len = 0
- nr_of_samples = list()
- for val in y_sorted.values():
- if len(val) > max_len:
- max_len = len(val)
- nr_of_samples.append(len(val))
- for key, val in y_sorted.items():
- if len(val) < max_len:
- val.extend([None for _ in range(max_len - len(val))])
-
- # Add plot traces
- traces = list()
- df = pd.DataFrame(y_sorted)
- df.head()
- y_max = list()
- for i, col in enumerate(df.columns):
- name = "{nr}. ({samples:02d} run{plural}) {name}".\
- format(nr=(i + 1),
- samples=nr_of_samples[i],
- plural='s' if nr_of_samples[i] > 1 else '',
- name=col.lower().replace('-ndrpdr', ''))
- if len(name) > 50:
- name_lst = name.split('-')
- name = ""
- split_name = True
- for segment in name_lst:
- if (len(name) + len(segment) + 1) > 50 and split_name:
- name += "<br> "
- split_name = False
- name += segment + '-'
- name = name[:-1]
-
- logging.debug(name)
- traces.append(plgo.Box(x=[str(i + 1) + '.'] * len(df[col]),
- y=[y / 1000000 if y else None for y in df[col]],
- name=name,
- **plot["traces"]))
- try:
- val_max = max(df[col])
- except ValueError as err:
- logging.error(repr(err))
- continue
- if val_max:
- y_max.append(int(val_max / 1000000) + 1)
-
- try:
- # Create plot
- layout = deepcopy(plot["layout"])
- if layout.get("title", None):
- layout["title"] = "<b>Packet Throughput:</b> {0}". \
- format(layout["title"])
- if y_max:
- layout["yaxis"]["range"] = [0, max(y_max)]
- plpl = plgo.Figure(data=traces, layout=layout)
-
- # Export Plot
- logging.info(" Writing file '{0}{1}'.".
- format(plot["output-file"], plot["output-file-type"]))
- ploff.plot(plpl, show_link=False, auto_open=False,
- filename='{0}{1}'.format(plot["output-file"],
- plot["output-file-type"]))
- except PlotlyError as err:
- logging.error(" Finished with error: {}".
- format(repr(err).replace("\n", " ")))