[lineplotter] babystep
This commit is contained in:
parent
fb4fc20442
commit
cf09642074
@ -1,8 +1,6 @@
|
|||||||
from nixview.data_models.tree_model import PropertyTreeItem
|
|
||||||
from nixview.util import dataview
|
|
||||||
from nixview.util.enums import PlotterTypes
|
from nixview.util.enums import PlotterTypes
|
||||||
from PyQt5.QtWidgets import QGroupBox, QHBoxLayout, QLabel, QPushButton, QSizePolicy, QSlider, QVBoxLayout, QWidget
|
from PyQt5.QtWidgets import QGroupBox, QHBoxLayout, QLabel, QPushButton, QSizePolicy, QSlider, QVBoxLayout, QWidget
|
||||||
from PyQt5.QtCore import QObject, pyqtSignal, Qt
|
from PyQt5.QtCore import pyqtSignal, Qt
|
||||||
import matplotlib
|
import matplotlib
|
||||||
matplotlib.use('Qt5Agg')
|
matplotlib.use('Qt5Agg')
|
||||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
|
||||||
@ -47,13 +45,16 @@ class MplCanvas(FigureCanvasQTAgg):
|
|||||||
|
|
||||||
|
|
||||||
class Plotter(MplCanvas):
|
class Plotter(MplCanvas):
|
||||||
def __init__(self, file_handler, item, parent=None) -> None:
|
def __init__(self, file_handler, item, data_view, parent=None) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
self._file_handler = file_handler
|
self._file_handler = file_handler
|
||||||
self._item = item
|
self._item = item
|
||||||
|
self._dataview = data_view
|
||||||
|
|
||||||
|
|
||||||
|
def current_view(self):
|
||||||
|
raise NotImplementedError("current_view is not implemented on the current plotter")
|
||||||
|
|
||||||
def show(self):
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
class EventPlotter(Plotter):
|
class EventPlotter(Plotter):
|
||||||
@ -221,8 +222,8 @@ class ImagePlotter(Plotter):
|
|||||||
class LinePlotter(Plotter):
|
class LinePlotter(Plotter):
|
||||||
|
|
||||||
def __init__(self, file_handler, item, data_view, xdim=-1, parent=None):
|
def __init__(self, file_handler, item, data_view, xdim=-1, parent=None):
|
||||||
super().__init__(file_handler, item, parent)
|
super().__init__(file_handler, item, data_view, parent)
|
||||||
self._dataview = data_view
|
|
||||||
self.dimensions = self._file_handler.request_dimensions(self._item.block_id, self._item.id)
|
self.dimensions = self._file_handler.request_dimensions(self._item.block_id, self._item.id)
|
||||||
self.lines = []
|
self.lines = []
|
||||||
self.dim_count = len(self._dataview.full_shape)
|
self.dim_count = len(self._dataview.full_shape)
|
||||||
@ -274,13 +275,13 @@ class LinePlotter(Plotter):
|
|||||||
x = self._file_handler.request_axis(self._item.block_id, self._item.id, 0, len(y), start)
|
x = self._file_handler.request_axis(self._item.block_id, self._item.id, 0, len(y), start)
|
||||||
|
|
||||||
if len(self.lines) == 0:
|
if len(self.lines) == 0:
|
||||||
l, = self.axes.plot(x, y, label=self._item.name)
|
l, = self.axis.plot(x, y, label=self._item.name)
|
||||||
self.lines.append(l)
|
self.lines.append(l)
|
||||||
else:
|
else:
|
||||||
self.lines[0].set_ydata(y)
|
self.lines[0].set_ydata(y)
|
||||||
self.lines[0].set_xdata(x)
|
self.lines[0].set_xdata(x)
|
||||||
|
|
||||||
self.axes.set_xlim([x[0], x[-1]])
|
self.axis.set_xlim([x[0], x[-1]])
|
||||||
|
|
||||||
def __draw_2d(self, start, end):
|
def __draw_2d(self, start, end):
|
||||||
if start < 0:
|
if start < 0:
|
||||||
@ -407,6 +408,7 @@ class PlotScreen(QWidget):
|
|||||||
|
|
||||||
def on_view_changed(self):
|
def on_view_changed(self):
|
||||||
print("view changed!")
|
print("view changed!")
|
||||||
|
print(self.plotter.current_view())
|
||||||
|
|
||||||
def plot(self, item):
|
def plot(self, item):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user