-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
dufte_comparison.py
76 lines (62 loc) · 2.31 KB
/
dufte_comparison.py
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
66
67
68
69
70
71
72
73
74
75
76
import matplotlib.pyplot as plt
import numpy as np
import matplotx
def line():
rng = np.random.default_rng(0)
offsets = [1.0, 1.50, 1.60]
labels = ["no balancing", "CRV-27", "CRV-27*"]
x0 = np.linspace(0.0, 3.0, 100)
y = [offset * x0 / (x0 + 1) + 0.1 * rng.random(len(x0)) for offset in offsets]
# default mpl
with plt.style.context("default"):
for yy, label in zip(y, labels):
plt.plot(x0, yy, label=label)
plt.xlabel("distance [m]")
plt.ylabel("voltage [V]")
plt.legend()
plt.savefig("ex1-mpl.svg", bbox_inches="tight")
plt.close()
# dufte
with plt.style.context(matplotx.styles.dufte):
for yy, label in zip(y, labels):
plt.plot(x0, yy, label=label)
plt.xlabel("distance [m]")
matplotx.ylabel_top("voltage [V]")
matplotx.line_labels()
plt.savefig("ex1-dufte.svg", bbox_inches="tight")
plt.close()
# dufte
with plt.style.context(matplotx.styles.duftify(matplotx.styles.dracula)):
for yy, label in zip(y, labels):
plt.plot(x0, yy, label=label)
plt.xlabel("distance [m]")
matplotx.ylabel_top("voltage [V]")
matplotx.line_labels()
plt.savefig("ex1-dufte-dracula.svg", bbox_inches="tight")
plt.close()
def bars():
labels = ["Australia", "Brazil", "China", "Germany", "Mexico", "United\nStates"]
vals = [21.65, 24.5, 6.95, 8.40, 21.00, 8.55]
xpos = range(len(vals))
with plt.style.context("default"):
plt.bar(xpos, vals)
plt.xticks(xpos, labels)
plt.title("average temperature [°C]")
plt.savefig("bars-mpl.svg", transparent=True, bbox_inches="tight")
plt.close()
with plt.style.context(matplotx.styles.dufte_bar):
plt.bar(xpos, vals)
plt.xticks(xpos, labels)
plt.title("average temperature [°C]")
plt.savefig("bars-dufte1.svg", transparent=True, bbox_inches="tight")
plt.close()
with plt.style.context(matplotx.styles.dufte_bar):
plt.bar(xpos, vals)
plt.xticks(xpos, labels)
matplotx.show_bar_values("{:.2f}")
plt.title("average temperature [°C]")
plt.savefig("bars-dufte2.svg", transparent=True, bbox_inches="tight")
plt.close()
if __name__ == "__main__":
line()
bars()