Commit 35c9da52 authored by Niels-Oliver Walkowski's avatar Niels-Oliver Walkowski
Browse files

capsulate components in UnivariateSequence

in order to offer plotting of multiple features
parent c516ddfd
......@@ -7,9 +7,17 @@ import matplotlib.ticker as plticker
class SequencePlot(object):
"""Key class for visualizations with two axis"""
def __init__(self, width=40, height=3):
def __init__(self, view, width=40, height=5):
self.width = width
self.height = height
self._x = self.get_xpos(view) # outsourcen in Frames Class und dann hier löschen
def get_xpos(self, view):
"""calculate frame numbers for x-ticks"""
# TODO Die Frame No. Range könnte ich auch besser zu einer Methode von Frames machen
return [nr for nr in range(view._frames.start, view._frames.end,
view._frame_step)] # um X-Achse Minuten anzeigen zu lassen
def _timelabels(self, val, pos):
min, sec = divmod(int(val), 60)
......@@ -66,6 +74,12 @@ class SequencePlot(object):
return (ax, axt)
def saveplt(self):
self.fig.tight_layout()
self.fig.set_size_inches(self.width, self.height)
self.fig.savefig("testexp.png", dpi=200)
class MultivariatePlot(SequencePlot):
"""Scatterplot that shows n features per frame"""
......@@ -98,27 +112,18 @@ class MultivariatePlot(SequencePlot):
class UnivariatePlot(SequencePlot):
"""Lineplot that shows one featur per fram"""
def __init__(self):
super(UnivariatePlot, self).__init__()
def __init__(self, view):
super(UnivariatePlot, self).__init__(view)
# TODO die können evtl. noch in die super class
self.fig = plt.figure()
self._ax = plt.axes()
self._ax, self._axt = self.ittenstyle(self._ax, view)
self.plot(view)
def plot(self, view):
# TODO Die Frame No. Range könnte ich auch besser zu einer Methode von Frames machen
x = [nr for nr in range(view._frames.start, view._frames.end,
view._frame_step)] # um X-Achse Minuten anzeigen zu lassen
self._ax, axt = self.ittenstyle(self._ax, view)
# Interpolation mit savitzky_golay funktioniert nicht
# contrast_points = savitzky_golay(np.array(contrast_points), 51, 7)
axt.plot(x, view)
self._axt.plot(self._x, view)
self.fig.tight_layout()
self.fig.set_size_inches(self.width, self.height)
self.fig.savefig("intest.png", dpi=200)
return self.fig, self._ax
return self.fig
......@@ -5,7 +5,7 @@ from itten.visuals import UnivariatePlot
movie = Movie(prefix='rec_', folder='../DHd-2017/Data/Frames/Rec/')
cont = UnivariateSequence(movie._frames)
cont.seqmean(frm_stp=100)
viz = UnivariatePlot()
viz = UnivariatePlot(cont)
viz.plot(cont)
# viz = MultivariatePlot()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment