added a logger for constructor calls
This commit is contained in:
parent
212da78933
commit
818dc0b2b0
|
@ -2,6 +2,7 @@ import pygtk
|
|||
import gobject
|
||||
import gtk
|
||||
|
||||
import matplotlib
|
||||
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
|
||||
from matplotlib.nxutils import points_inside_poly
|
||||
from matplotlib.figure import Figure
|
||||
|
@ -17,6 +18,13 @@ import fluents
|
|||
import logger
|
||||
import view
|
||||
|
||||
def plotlogger(func, name=None):
|
||||
def wrapped(parent, *args, **kw):
|
||||
parent.__args = args
|
||||
parent.__kw = kw
|
||||
return func(parent, *args, **kw)
|
||||
return wrapped
|
||||
|
||||
|
||||
class Plot(view.View):
|
||||
def __init__(self, title):
|
||||
|
@ -132,6 +140,7 @@ class LineViewPlot(Plot):
|
|||
|
||||
fixme: slow
|
||||
"""
|
||||
@plotlogger
|
||||
def __init__(self, dataset, major_axis=1, minor_axis=None, name="Line view"):
|
||||
Plot.__init__(self, name)
|
||||
self.dataset = dataset
|
||||
|
@ -233,7 +242,7 @@ class LineViewPlot(Plot):
|
|||
class ScatterMarkerPlot(Plot):
|
||||
"""The ScatterMarkerPlot is faster than regular scatterplot, but
|
||||
has no color and size options."""
|
||||
|
||||
@plotlogger
|
||||
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim,
|
||||
id_1, id_2, s=6, name="Scatter plot"):
|
||||
Plot.__init__(self, name)
|
||||
|
@ -306,12 +315,14 @@ class ScatterMarkerPlot(Plot):
|
|||
|
||||
class ScatterPlot(Plot):
|
||||
"""The ScatterPlot is slower than scattermarker, but has size option."""
|
||||
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2, c='b', s=30, sel_dim_2=None, name="Scatter plot"):
|
||||
@plotlogger
|
||||
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2, c='b', s=30, sel_dim_2=None, name="Scatter plot", **kw):
|
||||
|
||||
Plot.__init__(self, name)
|
||||
self.dataset_1 = dataset_1
|
||||
self.s = s
|
||||
self.c = c
|
||||
self.kw = kw
|
||||
self.current_dim = id_dim
|
||||
|
||||
x_index = dataset_1[sel_dim][id_1]
|
||||
|
@ -355,7 +366,8 @@ class ScatterPlot(Plot):
|
|||
def init_draw(self):
|
||||
lw = scipy.zeros(self.xaxis_data.shape)
|
||||
self.sc = self.axes.scatter(self.xaxis_data, self.yaxis_data,
|
||||
s=self.s, c=self.c, linewidth=lw, zorder=3)
|
||||
s=self.s, c=self.c, linewidth=lw,
|
||||
zorder=3, **self.kw)
|
||||
self.axes.axhline(0, color='k', lw=1., zorder=1)
|
||||
self.axes.axvline(0, color='k', lw=1., zorder=1)
|
||||
self.selection_collection = self.axes.scatter(self.xaxis_data,
|
||||
|
@ -449,6 +461,7 @@ class ScatterPlot(Plot):
|
|||
|
||||
|
||||
class ImagePlot(Plot):
|
||||
@plotlogger
|
||||
def __init__(self, dataset, **kw):
|
||||
Plot.__init__(self, kw.get('name', 'Image Plot'))
|
||||
self.dataset = dataset
|
||||
|
@ -469,7 +482,7 @@ class HistogramPlot(Plot):
|
|||
If dataset is 1-dim the current_dim is set and selections may
|
||||
be performed. For dataset> 1.dim the histogram is over all values
|
||||
and selections are not defined,"""
|
||||
|
||||
@plotlogger
|
||||
def __init__(self, dataset, **kw):
|
||||
Plot.__init__(self, kw['name'])
|
||||
self.dataset = dataset
|
||||
|
@ -556,6 +569,7 @@ class BarPlot(Plot):
|
|||
Ordinary bar plot for (column) vectors.
|
||||
For matrices there is one color for each row.
|
||||
"""
|
||||
@plotlogger
|
||||
def __init__(self, dataset, **kw):
|
||||
Plot.__init__(self, kw.get('name', 'Bar Plot'))
|
||||
self.dataset = dataset
|
||||
|
@ -564,8 +578,7 @@ class BarPlot(Plot):
|
|||
self.axes.grid(False)
|
||||
n, m = dataset.shape
|
||||
if m>1:
|
||||
sm = matplotlib.cm.ScalarMappable()
|
||||
clrs = sm.to_rgba(range(n))
|
||||
clrs = matplotlib.cm.ScalarMappable().to_rgba(range(n))
|
||||
for i, row in enumerate(dataset.asarray()):
|
||||
left = scipy.arange(i+1, m*n+1, n)
|
||||
height = row
|
||||
|
@ -584,6 +597,7 @@ class BarPlot(Plot):
|
|||
|
||||
|
||||
class NetworkPlot(Plot):
|
||||
@plotlogger
|
||||
def __init__(self, dataset, pos=None, nodecolor='b', nodesize=40,
|
||||
prog='neato', with_labels=False, name='Network Plot'):
|
||||
|
||||
|
@ -606,9 +620,9 @@ class NetworkPlot(Plot):
|
|||
|
||||
# Initial draw
|
||||
self.default_props = {'nodesize' : 50,
|
||||
'nodecolor' : 'gray',
|
||||
'edge_color' : (.5, .5, .5, 1),
|
||||
'edge_color_selected' : (1,0,0,1)}
|
||||
'nodecolor' : 'blue',
|
||||
'edge_color' : 'gray',
|
||||
'edge_color_selected' : 'red'}
|
||||
self.node_collection = None
|
||||
self.edge_collection = None
|
||||
self.node_labels = None
|
||||
|
@ -634,7 +648,7 @@ class NetworkPlot(Plot):
|
|||
self._pos,
|
||||
ax=self.axes,
|
||||
edge_color=edge_color)
|
||||
# edge color rgba-array
|
||||
# edge color rgba-arrays
|
||||
self._edge_color_rgba = scipy.repmat(ColorConverter().to_rgba(edge_color),
|
||||
self.graph.number_of_edges(),1)
|
||||
self._edge_color_selected = ColorConverter().to_rgba(self.default_props['edge_color_selected'])
|
||||
|
@ -693,6 +707,7 @@ class NetworkPlot(Plot):
|
|||
|
||||
|
||||
class VennPlot(Plot):
|
||||
@plotlogger
|
||||
def __init__(self, name="Venn diagram"):
|
||||
Plot.__init__(self, name)
|
||||
|
||||
|
|
Reference in New Issue