25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2KB

  1. from ui.components.plot_figure import PlotFrame
  2. from abc import ABC
  3. from matplotlib.figure import Figure
  4. from ui.plotters.plotter import Plotter
  5. class PredictionsPlot(PlotFrame):
  6. def __init__(self, parent):
  7. super().__init__(parent, height=32)
  8. self.plotter = PredictionsPlotter(self.figure)
  9. class PredictionsPlotter(Plotter, ABC):
  10. def __init__(self, figure: Figure):
  11. super().__init__(figure)
  12. self.axes = figure.add_subplot()
  13. self.clean_axes()
  14. def plot(self, data):
  15. self.axes.imshow(data, cmap='coolwarm', aspect='auto')
  16. for idx in range(10):
  17. self.axes.annotate(f"{idx}", xy=(idx - 0.2, 0.2))
  18. self.clean_axes()
  19. def clean_axes(self):
  20. # Remove axis ticks, labels, and spines
  21. self.axes.set_xticks([]) # Remove x-ticks
  22. self.axes.set_yticks([]) # Remove y-ticks
  23. self.axes.spines['top'].set_visible(False)
  24. self.axes.spines['bottom'].set_visible(False)
  25. self.axes.spines['left'].set_visible(False)
  26. self.axes.spines['right'].set_visible(False)
  27. self.axes.set_facecolor((0, 0, 0))
  28. def reset_plot(self):
  29. self.axes.clear()