Fix: Calculation of max value.
[csit.git] / resources / tools / presentation / generator_plots.py
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 """Algorithms to generate plots.
15 """
16
17
18 import logging
19 import pandas as pd
20 import plotly.offline as ploff
21 import plotly.graph_objs as plgo
22
23 from plotly.exceptions import PlotlyError
24 from collections import OrderedDict
25 from copy import deepcopy
26
27 from utils import mean
28
29
30 COLORS = ["SkyBlue", "Olive", "Purple", "Coral", "Indigo", "Pink",
31           "Chocolate", "Brown", "Magenta", "Cyan", "Orange", "Black",
32           "Violet", "Blue", "Yellow", "BurlyWood", "CadetBlue", "Crimson",
33           "DarkBlue", "DarkCyan", "DarkGreen", "Green", "GoldenRod",
34           "LightGreen", "LightSeaGreen", "LightSkyBlue", "Maroon",
35           "MediumSeaGreen", "SeaGreen", "LightSlateGrey"]
36
37
38 def generate_plots(spec, data):
39     """Generate all plots specified in the specification file.
40
41     :param spec: Specification read from the specification file.
42     :param data: Data to process.
43     :type spec: Specification
44     :type data: InputData
45     """
46
47     logging.info("Generating the plots ...")
48     for index, plot in enumerate(spec.plots):
49         try:
50             logging.info("  Plot nr {0}: {1}".format(index + 1,
51                                                      plot.get("title", "")))
52             plot["limits"] = spec.configuration["limits"]
53             eval(plot["algorithm"])(plot, data)
54             logging.info("  Done.")
55         except NameError as err:
56             logging.error("Probably algorithm '{alg}' is not defined: {err}".
57                           format(alg=plot["algorithm"], err=repr(err)))
58     logging.info("Done.")
59
60
61 def plot_performance_box(plot, input_data):
62     """Generate the plot(s) with algorithm: plot_performance_box
63     specified in the specification file.
64
65     :param plot: Plot to generate.
66     :param input_data: Data to process.
67     :type plot: pandas.Series
68     :type input_data: InputData
69     """
70
71     # Transform the data
72     plot_title = plot.get("title", "")
73     logging.info("    Creating the data set for the {0} '{1}'.".
74                  format(plot.get("type", ""), plot_title))
75     data = input_data.filter_data(plot)
76     if data is None:
77         logging.error("No data.")
78         return
79
80     # Prepare the data for the plot
81     y_vals = dict()
82     y_tags = dict()
83     for job in data:
84         for build in job:
85             for test in build:
86                 if y_vals.get(test["parent"], None) is None:
87                     y_vals[test["parent"]] = list()
88                     y_tags[test["parent"]] = test.get("tags", None)
89                 try:
90                     if test["type"] in ("NDRPDR", ):
91                         if "-pdr" in plot_title.lower():
92                             y_vals[test["parent"]].\
93                                 append(test["throughput"]["PDR"]["LOWER"])
94                         elif "-ndr" in plot_title.lower():
95                             y_vals[test["parent"]]. \
96                                 append(test["throughput"]["NDR"]["LOWER"])
97                         else:
98                             continue
99                     else:
100                         continue
101                 except (KeyError, TypeError):
102                     y_vals[test["parent"]].append(None)
103
104     # Sort the tests
105     order = plot.get("sort", None)
106     if order and y_tags:
107         y_sorted = OrderedDict()
108         y_tags_l = {s: [t.lower() for t in ts] for s, ts in y_tags.items()}
109         for tag in order:
110             logging.info(tag)
111             for suite, tags in y_tags_l.items():
112                 if "not " in tag:
113                     tag = tag.split(" ")[-1]
114                     if tag.lower() in tags:
115                         continue
116                 else:
117                     if tag.lower() not in tags:
118                         continue
119                 try:
120                     y_sorted[suite] = y_vals.pop(suite)
121                     y_tags_l.pop(suite)
122                     logging.info(suite)
123                 except KeyError as err:
124                     logging.error("Not found: {0}".format(err))
125                 finally:
126                     break
127     else:
128         y_sorted = y_vals
129
130     # Add None to the lists with missing data
131     max_len = 0
132     for val in y_sorted.values():
133         if len(val) > max_len:
134             max_len = len(val)
135     for key, val in y_sorted.items():
136         if len(val) < max_len:
137             val.extend([None for _ in range(max_len - len(val))])
138
139     # Add plot traces
140     traces = list()
141     df = pd.DataFrame(y_sorted)
142     df.head()
143     y_max = list()
144     for i, col in enumerate(df.columns):
145         name = "{0}. {1}".format(i + 1, col.lower().replace('-ndrpdrdisc', '').
146                                  replace('-ndrpdr', ''))
147         logging.info(name)
148         traces.append(plgo.Box(x=[str(i + 1) + '.'] * len(df[col]),
149                                y=[y / 1000000 if y else None for y in df[col]],
150                                name=name,
151                                **plot["traces"]))
152         try:
153             val_max = max(df[col])
154         except ValueError as err:
155             logging.error(err)
156             continue
157         if val_max:
158             y_max.append(int(val_max / 1000000) + 1)
159
160     try:
161         # Create plot
162         layout = deepcopy(plot["layout"])
163         if layout.get("title", None):
164             layout["title"] = "<b>Packet Throughput:</b> {0}". \
165                 format(layout["title"])
166         if y_max:
167             layout["yaxis"]["range"] = [0, max(y_max)]
168         plpl = plgo.Figure(data=traces, layout=layout)
169
170         # Export Plot
171         logging.info("    Writing file '{0}{1}'.".
172                      format(plot["output-file"], plot["output-file-type"]))
173         ploff.plot(plpl, show_link=False, auto_open=False,
174                    filename='{0}{1}'.format(plot["output-file"],
175                                             plot["output-file-type"]))
176     except PlotlyError as err:
177         logging.error("   Finished with error: {}".
178                       format(str(err).replace("\n", " ")))
179         return
180
181
182 def plot_latency_error_bars(plot, input_data):
183     """Generate the plot(s) with algorithm: plot_latency_error_bars
184     specified in the specification file.
185
186     :param plot: Plot to generate.
187     :param input_data: Data to process.
188     :type plot: pandas.Series
189     :type input_data: InputData
190     """
191
192     # Transform the data
193     plot_title = plot.get("title", "")
194     logging.info("    Creating the data set for the {0} '{1}'.".
195                  format(plot.get("type", ""), plot_title))
196     data = input_data.filter_data(plot)
197     if data is None:
198         logging.error("No data.")
199         return
200
201     # Prepare the data for the plot
202     y_tmp_vals = dict()
203     y_tags = dict()
204     for job in data:
205         for build in job:
206             for test in build:
207                 if y_tmp_vals.get(test["parent"], None) is None:
208                     y_tmp_vals[test["parent"]] = [
209                         list(),  # direction1, min
210                         list(),  # direction1, avg
211                         list(),  # direction1, max
212                         list(),  # direction2, min
213                         list(),  # direction2, avg
214                         list()   # direction2, max
215                     ]
216                     y_tags[test["parent"]] = test.get("tags", None)
217                 try:
218                     if test["type"] in ("NDRPDR", ):
219                         if "-pdr" in plot_title.lower():
220                             ttype = "PDR"
221                         elif "-ndr" in plot_title.lower():
222                             ttype = "NDR"
223                         else:
224                             continue
225                         y_tmp_vals[test["parent"]][0].append(
226                             test["latency"][ttype]["direction1"]["min"])
227                         y_tmp_vals[test["parent"]][1].append(
228                             test["latency"][ttype]["direction1"]["avg"])
229                         y_tmp_vals[test["parent"]][2].append(
230                             test["latency"][ttype]["direction1"]["max"])
231                         y_tmp_vals[test["parent"]][3].append(
232                             test["latency"][ttype]["direction2"]["min"])
233                         y_tmp_vals[test["parent"]][4].append(
234                             test["latency"][ttype]["direction2"]["avg"])
235                         y_tmp_vals[test["parent"]][5].append(
236                             test["latency"][ttype]["direction2"]["max"])
237                     else:
238                         continue
239                 except (KeyError, TypeError):
240                     pass
241
242     # Sort the tests
243     order = plot.get("sort", None)
244     if order and y_tags:
245         y_sorted = OrderedDict()
246         y_tags_l = {s: [t.lower() for t in ts] for s, ts in y_tags.items()}
247         for tag in order:
248             for suite, tags in y_tags_l.items():
249                 if tag.lower() in tags:
250                     try:
251                         y_sorted[suite] = y_tmp_vals.pop(suite)
252                         y_tags_l.pop(suite)
253                     except KeyError as err:
254                         logging.error("Not found: {0}".format(err))
255                     finally:
256                         break
257     else:
258         y_sorted = y_tmp_vals
259
260     x_vals = list()
261     y_vals = list()
262     y_mins = list()
263     y_maxs = list()
264     for key, val in y_sorted.items():
265         key = "-".join(key.split("-")[1:-1])
266         x_vals.append(key)  # dir 1
267         y_vals.append(mean(val[1]) if val[1] else None)
268         y_mins.append(mean(val[0]) if val[0] else None)
269         y_maxs.append(mean(val[2]) if val[2] else None)
270         x_vals.append(key)  # dir 2
271         y_vals.append(mean(val[4]) if val[4] else None)
272         y_mins.append(mean(val[3]) if val[3] else None)
273         y_maxs.append(mean(val[5]) if val[5] else None)
274
275     traces = list()
276     annotations = list()
277
278     for idx in range(len(x_vals)):
279         if not bool(int(idx % 2)):
280             direction = "West - East"
281         else:
282             direction = "East - West"
283         hovertext = ("Test: {test}<br>"
284                      "Direction: {dir}<br>".format(test=x_vals[idx],
285                                                    dir=direction))
286         if isinstance(y_maxs[idx], float):
287             hovertext += "Max: {max:.2f}uSec<br>".format(max=y_maxs[idx])
288         if isinstance(y_vals[idx], float):
289             hovertext += "Avg: {avg:.2f}uSec<br>".format(avg=y_vals[idx])
290         if isinstance(y_mins[idx], float):
291             hovertext += "Min: {min:.2f}uSec".format(min=y_mins[idx])
292
293         if isinstance(y_maxs[idx], float) and isinstance(y_vals[idx], float):
294             array = [y_maxs[idx] - y_vals[idx], ]
295         else:
296             array = [None, ]
297         if isinstance(y_mins[idx], float) and isinstance(y_vals[idx], float):
298             arrayminus = [y_vals[idx] - y_mins[idx], ]
299         else:
300             arrayminus = [None, ]
301         traces.append(plgo.Scatter(
302             x=[idx, ],
303             y=[y_vals[idx], ],
304             name=x_vals[idx],
305             legendgroup=x_vals[idx],
306             showlegend=bool(int(idx % 2)),
307             mode="markers",
308             error_y=dict(
309                 type='data',
310                 symmetric=False,
311                 array=array,
312                 arrayminus=arrayminus,
313                 color=COLORS[int(idx / 2)]
314             ),
315             marker=dict(
316                 size=10,
317                 color=COLORS[int(idx / 2)],
318             ),
319             text=hovertext,
320             hoverinfo="text",
321         ))
322         annotations.append(dict(
323             x=idx,
324             y=0,
325             xref="x",
326             yref="y",
327             xanchor="center",
328             yanchor="top",
329             text="E-W" if bool(int(idx % 2)) else "W-E",
330             font=dict(
331                 size=16,
332             ),
333             align="center",
334             showarrow=False
335         ))
336
337     try:
338         # Create plot
339         logging.info("    Writing file '{0}{1}'.".
340                      format(plot["output-file"], plot["output-file-type"]))
341         layout = deepcopy(plot["layout"])
342         if layout.get("title", None):
343             layout["title"] = "<b>Packet Latency:</b> {0}".\
344                 format(layout["title"])
345         layout["annotations"] = annotations
346         plpl = plgo.Figure(data=traces, layout=layout)
347
348         # Export Plot
349         ploff.plot(plpl,
350                    show_link=False, auto_open=False,
351                    filename='{0}{1}'.format(plot["output-file"],
352                                             plot["output-file-type"]))
353     except PlotlyError as err:
354         logging.error("   Finished with error: {}".
355                       format(str(err).replace("\n", " ")))
356         return
357
358
359 def plot_throughput_speedup_analysis(plot, input_data):
360     """Generate the plot(s) with algorithm:
361     plot_throughput_speedup_analysis
362     specified in the specification file.
363
364     :param plot: Plot to generate.
365     :param input_data: Data to process.
366     :type plot: pandas.Series
367     :type input_data: InputData
368     """
369
370     # Transform the data
371     plot_title = plot.get("title", "")
372     logging.info("    Creating the data set for the {0} '{1}'.".
373                  format(plot.get("type", ""), plot_title))
374     data = input_data.filter_data(plot)
375     if data is None:
376         logging.error("No data.")
377         return
378
379     y_vals = dict()
380     y_tags = dict()
381     for job in data:
382         for build in job:
383             for test in build:
384                 if y_vals.get(test["parent"], None) is None:
385                     y_vals[test["parent"]] = {"1": list(),
386                                               "2": list(),
387                                               "4": list()}
388                     y_tags[test["parent"]] = test.get("tags", None)
389                 try:
390                     if test["type"] in ("NDRPDR",):
391                         if "-pdr" in plot_title.lower():
392                             ttype = "PDR"
393                         elif "-ndr" in plot_title.lower():
394                             ttype = "NDR"
395                         else:
396                             continue
397                         if "1C" in test["tags"]:
398                             y_vals[test["parent"]]["1"]. \
399                                 append(test["throughput"][ttype]["LOWER"])
400                         elif "2C" in test["tags"]:
401                             y_vals[test["parent"]]["2"]. \
402                                 append(test["throughput"][ttype]["LOWER"])
403                         elif "4C" in test["tags"]:
404                             y_vals[test["parent"]]["4"]. \
405                                 append(test["throughput"][ttype]["LOWER"])
406                 except (KeyError, TypeError):
407                     pass
408
409     if not y_vals:
410         logging.warning("No data for the plot '{}'".
411                         format(plot.get("title", "")))
412         return
413
414     y_1c_max = dict()
415     for test_name, test_vals in y_vals.items():
416         for key, test_val in test_vals.items():
417             if test_val:
418                 y_vals[test_name][key] = sum(test_val) / len(test_val)
419                 if key == "1":
420                     y_1c_max[test_name] = max(test_val) / 1000000.0
421
422     vals = dict()
423     y_max = list()
424     nic_limit = 0
425     lnk_limit = 0
426     pci_limit = plot["limits"]["pci"]["pci-g3-x8"]
427     for test_name, test_vals in y_vals.items():
428         if test_vals["1"]:
429             name = "-".join(test_name.split('-')[1:-1])
430
431             vals[name] = dict()
432             y_val_1 = test_vals["1"] / 1000000.0
433             y_val_2 = test_vals["2"] / 1000000.0 if test_vals["2"] else None
434             y_val_4 = test_vals["4"] / 1000000.0 if test_vals["4"] else None
435
436             vals[name]["val"] = [y_val_1, y_val_2, y_val_4]
437             vals[name]["rel"] = [1.0, None, None]
438             vals[name]["ideal"] = [y_1c_max[test_name],
439                                    y_1c_max[test_name] * 2,
440                                    y_1c_max[test_name] * 4]
441             vals[name]["diff"] = \
442                 [(y_val_1 - y_1c_max[test_name]) * 100 / y_val_1, None, None]
443
444             try:
445                 val_max = max(max(vals[name]["val"], vals[name]["ideal"]))
446             except ValueError as err:
447                 logging.error(err)
448                 continue
449             if val_max:
450                 y_max.append(int((val_max / 10) + 1) * 10)
451
452             if y_val_2:
453                 vals[name]["rel"][1] = round(y_val_2 / y_val_1, 2)
454                 vals[name]["diff"][1] = \
455                     (y_val_2 - vals[name]["ideal"][1]) * 100 / y_val_2
456             if y_val_4:
457                 vals[name]["rel"][2] = round(y_val_4 / y_val_1, 2)
458                 vals[name]["diff"][2] = \
459                     (y_val_4 - vals[name]["ideal"][2]) * 100 / y_val_4
460
461         # Limits:
462         if "x520" in test_name:
463             limit = plot["limits"]["nic"]["x520"]
464         elif "x710" in test_name:
465             limit = plot["limits"]["nic"]["x710"]
466         elif "xxv710" in test_name:
467             limit = plot["limits"]["nic"]["xxv710"]
468         elif "xl710" in test_name:
469             limit = plot["limits"]["nic"]["xl710"]
470         else:
471             limit = 0
472         if limit > nic_limit:
473             nic_limit = limit
474
475         mul = 2 if "ge2p" in test_name else 1
476         if "10ge" in test_name:
477             limit = plot["limits"]["link"]["10ge"] * mul
478         elif "25ge" in test_name:
479             limit = plot["limits"]["link"]["25ge"] * mul
480         elif "40ge" in test_name:
481             limit = plot["limits"]["link"]["40ge"] * mul
482         elif "100ge" in test_name:
483             limit = plot["limits"]["link"]["100ge"] * mul
484         else:
485             limit = 0
486         if limit > lnk_limit:
487             lnk_limit = limit
488
489     # Sort the tests
490     order = plot.get("sort", None)
491     if order and y_tags:
492         y_sorted = OrderedDict()
493         y_tags_l = {s: [t.lower() for t in ts] for s, ts in y_tags.items()}
494         for tag in order:
495             for test, tags in y_tags_l.items():
496                 if tag.lower() in tags:
497                     name = "-".join(test.split('-')[1:-1])
498                     try:
499                         y_sorted[name] = vals.pop(name)
500                         y_tags_l.pop(test)
501                     except KeyError as err:
502                         logging.error("Not found: {0}".format(err))
503                     finally:
504                         break
505     else:
506         y_sorted = vals
507
508     traces = list()
509     annotations = list()
510     x_vals = [1, 2, 4]
511
512     # Limits:
513     try:
514         threshold = 1.1 * max(y_max)  # 10%
515     except ValueError as err:
516         logging.error(err)
517         return
518     nic_limit /= 1000000.0
519     if nic_limit < threshold:
520         traces.append(plgo.Scatter(
521             x=x_vals,
522             y=[nic_limit, ] * len(x_vals),
523             name="NIC: {0:.2f}Mpps".format(nic_limit),
524             showlegend=False,
525             mode="lines",
526             line=dict(
527                 dash="dot",
528                 color=COLORS[-1],
529                 width=1),
530             hoverinfo="none"
531         ))
532         annotations.append(dict(
533             x=1,
534             y=nic_limit,
535             xref="x",
536             yref="y",
537             xanchor="left",
538             yanchor="bottom",
539             text="NIC: {0:.2f}Mpps".format(nic_limit),
540             font=dict(
541                 size=14,
542                 color=COLORS[-1],
543             ),
544             align="left",
545             showarrow=False
546         ))
547         y_max.append(int((nic_limit / 10) + 1) * 10)
548
549     lnk_limit /= 1000000.0
550     if lnk_limit < threshold:
551         traces.append(plgo.Scatter(
552             x=x_vals,
553             y=[lnk_limit, ] * len(x_vals),
554             name="Link: {0:.2f}Mpps".format(lnk_limit),
555             showlegend=False,
556             mode="lines",
557             line=dict(
558                 dash="dot",
559                 color=COLORS[-2],
560                 width=1),
561             hoverinfo="none"
562         ))
563         annotations.append(dict(
564             x=1,
565             y=lnk_limit,
566             xref="x",
567             yref="y",
568             xanchor="left",
569             yanchor="bottom",
570             text="Link: {0:.2f}Mpps".format(lnk_limit),
571             font=dict(
572                 size=14,
573                 color=COLORS[-2],
574             ),
575             align="left",
576             showarrow=False
577         ))
578         y_max.append(int((lnk_limit / 10) + 1) * 10)
579
580     pci_limit /= 1000000.0
581     if pci_limit < threshold:
582         traces.append(plgo.Scatter(
583             x=x_vals,
584             y=[pci_limit, ] * len(x_vals),
585             name="PCIe: {0:.2f}Mpps".format(pci_limit),
586             showlegend=False,
587             mode="lines",
588             line=dict(
589                 dash="dot",
590                 color=COLORS[-3],
591                 width=1),
592             hoverinfo="none"
593         ))
594         annotations.append(dict(
595             x=1,
596             y=pci_limit,
597             xref="x",
598             yref="y",
599             xanchor="left",
600             yanchor="bottom",
601             text="PCIe: {0:.2f}Mpps".format(pci_limit),
602             font=dict(
603                 size=14,
604                 color=COLORS[-3],
605             ),
606             align="left",
607             showarrow=False
608         ))
609         y_max.append(int((pci_limit / 10) + 1) * 10)
610
611     # Perfect and measured:
612     cidx = 0
613     for name, val in y_sorted.iteritems():
614         hovertext = list()
615         for idx in range(len(val["val"])):
616             htext = ""
617             if isinstance(val["val"][idx], float):
618                 htext += "value: {0:.2f}Mpps<br>".format(val["val"][idx])
619             if isinstance(val["diff"][idx], float):
620                 htext += "diff: {0:.0f}%<br>".format(round(val["diff"][idx]))
621             if isinstance(val["rel"][idx], float):
622                 htext += "speedup: {0:.2f}".format(val["rel"][idx])
623             hovertext.append(htext)
624         traces.append(plgo.Scatter(x=x_vals,
625                                    y=val["val"],
626                                    name=name,
627                                    legendgroup=name,
628                                    mode="lines+markers",
629                                    line=dict(
630                                        color=COLORS[cidx],
631                                        width=2),
632                                    marker=dict(
633                                        symbol="circle",
634                                        size=10
635                                    ),
636                                    text=hovertext,
637                                    hoverinfo="text+name"
638                                    ))
639         traces.append(plgo.Scatter(x=x_vals,
640                                    y=val["ideal"],
641                                    name="{0} perfect".format(name),
642                                    legendgroup=name,
643                                    showlegend=False,
644                                    mode="lines",
645                                    line=dict(
646                                        color=COLORS[cidx],
647                                        width=2,
648                                        dash="dash"),
649                                    text=["perfect: {0:.2f}Mpps".format(y)
650                                          for y in val["ideal"]],
651                                    hoverinfo="text"
652                                    ))
653         cidx += 1
654
655     try:
656         # Create plot
657         logging.info("    Writing file '{0}{1}'.".
658                      format(plot["output-file"], plot["output-file-type"]))
659         layout = deepcopy(plot["layout"])
660         if layout.get("title", None):
661             layout["title"] = "<b>Speedup Multi-core:</b> {0}". \
662                 format(layout["title"])
663         layout["annotations"].extend(annotations)
664         plpl = plgo.Figure(data=traces, layout=layout)
665
666         # Export Plot
667         ploff.plot(plpl,
668                    show_link=False, auto_open=False,
669                    filename='{0}{1}'.format(plot["output-file"],
670                                             plot["output-file-type"]))
671     except PlotlyError as err:
672         logging.error("   Finished with error: {}".
673                       format(str(err).replace("\n", " ")))
674         return
675
676
677 def plot_http_server_performance_box(plot, input_data):
678     """Generate the plot(s) with algorithm: plot_http_server_performance_box
679     specified in the specification file.
680
681     :param plot: Plot to generate.
682     :param input_data: Data to process.
683     :type plot: pandas.Series
684     :type input_data: InputData
685     """
686
687     # Transform the data
688     logging.info("    Creating the data set for the {0} '{1}'.".
689                  format(plot.get("type", ""), plot.get("title", "")))
690     data = input_data.filter_data(plot)
691     if data is None:
692         logging.error("No data.")
693         return
694
695     # Prepare the data for the plot
696     y_vals = dict()
697     for job in data:
698         for build in job:
699             for test in build:
700                 if y_vals.get(test["name"], None) is None:
701                     y_vals[test["name"]] = list()
702                 try:
703                     y_vals[test["name"]].append(test["result"])
704                 except (KeyError, TypeError):
705                     y_vals[test["name"]].append(None)
706
707     # Add None to the lists with missing data
708     max_len = 0
709     for val in y_vals.values():
710         if len(val) > max_len:
711             max_len = len(val)
712     for key, val in y_vals.items():
713         if len(val) < max_len:
714             val.extend([None for _ in range(max_len - len(val))])
715
716     # Add plot traces
717     traces = list()
718     df = pd.DataFrame(y_vals)
719     df.head()
720     for i, col in enumerate(df.columns):
721         name = "{0}. {1}".format(i + 1, col.lower().replace('-cps', '').
722                                  replace('-rps', ''))
723         traces.append(plgo.Box(x=[str(i + 1) + '.'] * len(df[col]),
724                                y=df[col],
725                                name=name,
726                                **plot["traces"]))
727     try:
728         # Create plot
729         plpl = plgo.Figure(data=traces, layout=plot["layout"])
730
731         # Export Plot
732         logging.info("    Writing file '{0}{1}'.".
733                      format(plot["output-file"], plot["output-file-type"]))
734         ploff.plot(plpl, show_link=False, auto_open=False,
735                    filename='{0}{1}'.format(plot["output-file"],
736                                             plot["output-file-type"]))
737     except PlotlyError as err:
738         logging.error("   Finished with error: {}".
739                       format(str(err).replace("\n", " ")))
740         return