-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_control_seq.py
58 lines (44 loc) · 1.7 KB
/
plot_control_seq.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
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 10})
import json
import os, sys
import numpy as np
if __name__ == "__main__":
fname = sys.argv[1]
data = np.loadtxt(fname)
fig, ax = plt.subplots(1, figsize=(7,2.5))
# output profile and set point
y = ax.plot(data[:,0],data[:,1], label='$y$')
yset = ax.plot(data[:,0],data[:,2], label=r'$y_{set}$')
ax.set_xlabel('Time')
ax.set_ylabel('Temperature')
# input profile
axtwin = ax.twinx()
u = axtwin.plot(data[:,0], data[:,3], label=r'$u$', color='red', linestyle='--')
axtwin.set_ylabel('Power', color='red')
axtwin.tick_params('y', colors='red')
# shrink the axis for the legend on top
box = ax.get_position()
# Legend underneath
#axlegend.set_position([box.x0, box.y0 + box.height * 0.1,
# box.width, box.height * 0.9])
# Legend above
ax.set_position([box.x0, box.y0 + box.height*0.05,
box.width, box.height * 0.9])
alllines = y + yset + u
alllabels = [l.get_label() for l in alllines]
ax.legend(alllines, alllabels, ncol=3, bbox_to_anchor = (0, 1.02, 1, 0.2), loc='upper center')
#ax.legend(alllines, alllabels, ncol=3, bbox_to_anchor = (1, 0), loc='lower right', bbox_transform=fig.transFigure)
plt.tight_layout()
plt.show()
print(np.sum(np.abs(data[:,1]-data[:,2])))
print(np.sum([np.abs(data[i+1,3]-data[i,3]) for i in range(len(data[:,3])-1)]))
#fig, ax = plt.subplots(1, figsize=(7,2.5))
#ax.plot(data[:,0],data[:,3], label='System')
#ax.set_xlabel('Time')
#ax.set_ylabel('Power')
#ax.legend(loc='best')
#plt.tight_layout()
#plt.show()