Plot sequential log data.
(self, entry_type:str, x:str, y:str, smoothness:int=0)
| 336 | return list(keys) |
| 337 | |
| 338 | def plot(self, entry_type:str, x:str, y:str, smoothness:int=0): |
| 339 | """ Plot sequential log data. """ |
| 340 | |
| 341 | query_x = self._decode(x) |
| 342 | query_y = self._decode(y) |
| 343 | |
| 344 | for idx, (log, name) in enumerate(zip(self.logs, self.log_names)): |
| 345 | log = log[entry_type] |
| 346 | |
| 347 | if smoothness > 1: |
| 348 | avg = MovingAverage(smoothness) |
| 349 | |
| 350 | _x = [] |
| 351 | _y = [] |
| 352 | |
| 353 | for datum in log: |
| 354 | val_x = self._follow(datum, query_x) |
| 355 | val_y = self._follow(datum, query_y) |
| 356 | |
| 357 | if val_x is not None and val_y is not None: |
| 358 | if smoothness > 1: |
| 359 | avg.append(val_y) |
| 360 | val_y = avg.get_avg() |
| 361 | |
| 362 | if len(avg) < smoothness // 10: |
| 363 | continue |
| 364 | |
| 365 | _x.append(val_x) |
| 366 | _y.append(val_y) |
| 367 | |
| 368 | plt.plot(_x, _y, color=self._color(idx), label=name) |
| 369 | |
| 370 | plt.title(y.replace('x.', entry_type + '.')) |
| 371 | plt.legend() |
| 372 | plt.grid(linestyle=':', linewidth=0.5) |
| 373 | plt.show() |
| 374 | |
| 375 | def bar(self, entry_type:str, x:str, labels:list=None, diff:bool=False, x_idx:int=-1): |
| 376 | """ Plot a bar chart. The result of x should be list or dictionary. """ |