-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
65 lines (55 loc) · 1.67 KB
/
plot.py
File metadata and controls
65 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from collections import OrderedDict
import numpy as np
import matplotlib.pyplot as plt
from pint import UnitRegistry
ureg = UnitRegistry()
ureg.define("MBps = 1 * megabyte / second")
ureg.define("KBps = 1 * kilobyte / second")
def graph_fio(FIO_RESULTS):
with plt.xkcd():
fig, ax = plt.subplots()
ax.set_title(f"FIO report")
ax.set_xlabel("RW Speed [MBps]")
y_values = np.arange(len(FIO_RESULTS))
ax.set_yticks(y_values + 0.2)
ax.set_yticklabels(FIO_RESULTS.keys())
n = len(FIO_RESULTS)
ax.barh(
y_values - 0.2 * 2,
[fio[0].magnitude for fio in FIO_RESULTS.values()],
height=0.2,
label="0",
)
ax.barh(
y_values - 0.2 * 1,
[fio[1].magnitude for fio in FIO_RESULTS.values()],
height=0.2,
label="1",
)
ax.barh(
y_values + 0.2 * 0,
[fio[2].magnitude for fio in FIO_RESULTS.values()],
height=0.2,
label="2",
)
ax.barh(
y_values + 0.2 * 1,
[fio[3].magnitude for fio in FIO_RESULTS.values()],
height=0.2,
label="3",
)
ax.grid(False, axis="x")
legend = ax.legend()
plt.tight_layout()
plt.show()
return fig, ax
def show_plots(DATA):
FIO_RESULTS = OrderedDict()
for contestant, data in DATA.items():
fios = data["fio"]
fios_rw = [
ureg(f'{fio["speed_rw"]} {fio["speed_units"]}').to("MBps") for fio in fios
]
FIO_RESULTS[contestant] = fios_rw
fig, ax = graph_fio(FIO_RESULTS)
return fig, ax