10 from PyQt5
import QtCore, QtWidgets
13 matplotlib.use(
"Qt5Agg")
14 from matplotlib.backends.backend_qt5agg
import FigureCanvasQTAgg
as FigureCanvas
15 from matplotlib.figure
import Figure
19 """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" 20 def __init__(self, parent=None, width=5, height=4, dpi=100):
21 fig = Figure(figsize=(width, height), dpi=dpi)
22 self.
axes = fig.add_subplot(111)
29 FigureCanvas.__init__(self, fig)
30 self.setParent(parent)
32 FigureCanvas.setSizePolicy(self,
33 QtWidgets.QSizePolicy.Expanding,
34 QtWidgets.QSizePolicy.Expanding)
35 FigureCanvas.updateGeometry(self)
39 Compute Initial Figure Function 43 class StaticPlot(MainPlot):
48 def __init__(self, x_list, y_list, *args, **kwargs):
49 MainPlot.__init__(self, *args, **kwargs)
64 self.axes.set_ylim(0, 1)
65 self.axes.set_xlim(0, len(self.x_list)-1)
66 self.axes.plot(self.x_list, self.y_list,
'-r')
74 def __init__(self, ui_class, potc_main_dict, *args, **kwargs):
75 MainPlot.__init__(self, *args, **kwargs)
79 timer = QtCore.QTimer(self)
93 predict_list = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Predict']['Nominal']['POTC']"))
94 predict_time_line = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Predict']['Nominal']['Time']"))
96 actual_list = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Actual']['Nominal']['POTC']"))
97 actual_time_line = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Actual']['Nominal']['Time']"))
99 predict_sb_list = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Predict']['Sensor Based']['POTC']"))
100 predict_sb_time_line = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Predict']['Sensor Based']['Time']"))
102 actual_sb_list = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Actual']['Sensor Based']['POTC']"))
103 actual_sb_time_line = list(eval(
"self.ui_class." + self.potc_main_dict +
"['Actual']['Sensor Based']['Time']"))
105 self.axes.set_ylim(0, 1)
107 if len(predict_time_line) >= len(actual_time_line):
108 self.axes.set_xlim(0, len(predict_time_line)-1)
111 self.axes.set_xlim(0, len(actual_time_line)-1)
113 self.axes.plot(predict_time_line, predict_list,
'-or', label=
"Predict")
114 self.axes.plot(actual_time_line, actual_list,
'-ob', label=
"Actual")
116 self.axes.plot(predict_sb_time_line, predict_sb_list,
'-oy', label=
"Predict SB")
117 self.axes.plot(actual_sb_time_line, actual_sb_list,
'-og', label=
"Actual SB")
119 self.axes.legend(loc=
'lower left', fontsize=
'small')
125 Create Simulation POTC Plot 128 def __init__(self, ui_class, x_list, y_list, *args, **kwargs):
129 MainPlot.__init__(self, *args, **kwargs)
136 timer = QtCore.QTimer(self)
150 self.x_list = list(eval(
"self.ui_class." + self.x_list_name))
151 self.y_list = list(eval(
"self.ui_class." + self.y_list_name))
153 self.axes.set_ylim(0, 1)
154 self.axes.set_xlim(0, len(self.x_list)-1)
156 self.axes.plot(self.x_list, self.y_list,
'-r')
168 self.axes.set_ylim(0, 1)
169 self.axes.set_xlim(0, len(self.
x_list)-1)
181 def __init__(self, ui_class, ui_parameter, ui_time_parameter, *args, **kwargs):
182 MainPlot.__init__(self, *args, **kwargs)
187 timer = QtCore.QTimer(self)
202 return np.floor(np.abs(np.log10(decimal_number)))
212 self.x_list.append(plot_time)
213 self.y_list.append(float(eval(
"self.ui_class." + self.
ui_parameter +
".text()")))
215 read_value = str(eval(
"self.ui_class." + self.
ui_parameter +
".text()"))
217 if read_value
not in (
"",
"0.0"):
220 if read_value.find(
'e') != -1:
221 temp_limit_1 = read_value.split(
'e-')
222 value_min = int(temp_limit_1[1]) - 1
223 value_max = value_min + 2
226 zero_count = self.
num_zeros(float(read_value))
227 value_min = int(zero_count)
228 value_max = value_min + 1
230 self.axes.set_ylim((1.0 * pow(10, (-1 * value_max))), (1.0 * pow(10, (-1 * value_min))))
240 self.axes.set_xlim(left, right)
244 except Exception
as err:
245 print(
"\nError: DynamicPlot\n")
251 Create Reliability Plot 254 def __init__(self, ui_class, ui_parameter, ui_time_parameter, scale_list, *args, **kwargs):
255 MainPlot.__init__(self, *args, **kwargs)
261 timer = QtCore.QTimer(self)
277 self.x_list.append(plot_time)
278 self.y_list.append(float(eval(
"self.ui_class." + self.
ui_parameter +
".text()")))
283 self.axes.set_ylim(0, 1)
296 self.axes.set_xlim(left, right)
def num_zeros(cls, decimal_number)
def __init__(self, x_list, y_list, args, kwargs)
def compute_initial_figure(self)
def compute_initial_figure(self)
def compute_initial_figure(self)
def __init__(self, ui_class, potc_main_dict, args, kwargs)
def __init__(self, ui_class, x_list, y_list, args, kwargs)
def __init__(self, parent=None, width=5, height=4, dpi=100)
def compute_initial_figure(self)
def __init__(self, ui_class, ui_parameter, ui_time_parameter, args, kwargs)
def __init__(self, ui_class, ui_parameter, ui_time_parameter, scale_list, args, kwargs)
def compute_initial_figure(self)
def compute_initial_figure(self)