updated Lineview and Plot
This commit is contained in:
parent
fc8b2e601f
commit
a5c5987fc3
|
@ -233,7 +233,11 @@ class Plot (gtk.Frame):
|
||||||
self.title = title
|
self.title = title
|
||||||
self.selection_listener = None
|
self.selection_listener = None
|
||||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||||
|
self._background = None
|
||||||
|
self.canvas = None
|
||||||
|
self.fig = Figure(figsize=(5,4), dpi=72)
|
||||||
|
self.canvas = FigureCanvas(self.fig)
|
||||||
|
self.fig.set_facecolor('white')
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
@ -252,7 +256,6 @@ class Plot (gtk.Frame):
|
||||||
def get_toolbar(self):
|
def get_toolbar(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class EmptyView (Plot):
|
class EmptyView (Plot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Plot.__init__(self, 'Empty view')
|
Plot.__init__(self, 'Empty view')
|
||||||
|
@ -332,6 +335,7 @@ class NavToolbar(NavigationToolbar2):
|
||||||
self._select_callback(lastx, lasty, x, y)
|
self._select_callback(lastx, lasty, x, y)
|
||||||
|
|
||||||
self._xypress = None
|
self._xypress = None
|
||||||
|
self.push_current()
|
||||||
self.release(event)
|
self.release(event)
|
||||||
|
|
||||||
def mouse_move(self, event):
|
def mouse_move(self, event):
|
||||||
|
@ -393,9 +397,8 @@ class LineViewPlot(Plot):
|
||||||
self._data = dataset.asarray()
|
self._data = dataset.asarray()
|
||||||
self.dataset = dataset
|
self.dataset = dataset
|
||||||
Plot.__init__(self, name)
|
Plot.__init__(self, name)
|
||||||
fig = Figure(figsize=(5,4), dpi=72)
|
self.ax = self.fig.add_subplot(111)
|
||||||
self.canvas = FigureCanvas(fig)
|
self.ax.set_title(self.get_title())
|
||||||
self.ax = fig.add_subplot(111)
|
|
||||||
self.current_dim = self.dataset.get_dim_name(major_axis)
|
self.current_dim = self.dataset.get_dim_name(major_axis)
|
||||||
if len(self._data.shape)==2 and not minor_axis:
|
if len(self._data.shape)==2 and not minor_axis:
|
||||||
minor_axis = major_axis-1
|
minor_axis = major_axis-1
|
||||||
|
@ -404,10 +407,8 @@ class LineViewPlot(Plot):
|
||||||
x_axis = scipy.arrayrange(self._data.shape[minor_axis])
|
x_axis = scipy.arrayrange(self._data.shape[minor_axis])
|
||||||
for i in range(self._data.shape[major_axis]):
|
for i in range(self._data.shape[major_axis]):
|
||||||
yi = scipy.take(self._data,[i],axis=major_axis)
|
yi = scipy.take(self._data,[i],axis=major_axis)
|
||||||
l, = self.ax.plot(x_axis,yi,animated=True)
|
l, = self.ax.plot(x_axis,yi,'k',alpha=.05,animated=True)
|
||||||
self.line_collection[i] = l
|
self.line_collection[i] = l
|
||||||
# store clean state
|
|
||||||
self._background = self.canvas.copy_from_bbox(self.ax.bbox)
|
|
||||||
|
|
||||||
self.add(self.canvas)
|
self.add(self.canvas)
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
|
@ -415,18 +416,27 @@ class LineViewPlot(Plot):
|
||||||
# We use a regular toolbar as we don't need selections
|
# We use a regular toolbar as we don't need selections
|
||||||
self._toolbar = NavigationToolbar2(self.canvas, None)
|
self._toolbar = NavigationToolbar2(self.canvas, None)
|
||||||
self._toolbar.set_property('show-arrow', False)
|
self._toolbar.set_property('show-arrow', False)
|
||||||
|
self.canvas.mpl_connect('resize_event',self.clear_background)
|
||||||
|
|
||||||
def get_toolbar(self):
|
def get_toolbar(self):
|
||||||
return self._toolbar
|
return self._toolbar
|
||||||
|
|
||||||
|
def clear_background(self,event):
|
||||||
|
self._background = None
|
||||||
|
|
||||||
def selection_changed(self, selection):
|
def selection_changed(self, selection):
|
||||||
ids = selection[self.current_dim] # current identifiers
|
ids = selection[self.current_dim] # current identifiers
|
||||||
index = self.dataset.get_indices(self.current_dim, ids)
|
index = self.dataset.get_indices(self.current_dim, ids)
|
||||||
if self._background is not None:
|
if self._background is None:
|
||||||
|
print "background needs copy"
|
||||||
|
self._background = self.canvas.copy_from_bbox(self.ax.bbox)
|
||||||
|
print self.ax.bbox.get_bounds()
|
||||||
self.canvas.restore_region(self._background)
|
self.canvas.restore_region(self._background)
|
||||||
if index:
|
if index:
|
||||||
for i in index:
|
for i in index:
|
||||||
self.line_collection[i].set_visible(True)
|
self.line_collection[i].set_visible(True)
|
||||||
|
self.line_collection[i].set_color('r')
|
||||||
|
self.line_collection[i].set_alpha(1.0)
|
||||||
self.ax.draw_artist(self.line_collection[i])
|
self.ax.draw_artist(self.line_collection[i])
|
||||||
self.canvas.blit()
|
self.canvas.blit()
|
||||||
|
|
||||||
|
@ -435,8 +445,7 @@ class ScatterMarkerPlot(Plot):
|
||||||
has no color and size options."""
|
has no color and size options."""
|
||||||
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2, name="Scatter plot"):
|
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2, name="Scatter plot"):
|
||||||
Plot.__init__(self, name)
|
Plot.__init__(self, name)
|
||||||
fig = Figure(figsize=(5,4), dpi=72)
|
self.ax = ax = self.fig.add_subplot(111)
|
||||||
self.ax = ax = fig.add_subplot(111)
|
|
||||||
self.current_dim = id_dim
|
self.current_dim = id_dim
|
||||||
self.dataset_1 = dataset_1
|
self.dataset_1 = dataset_1
|
||||||
|
|
||||||
|
@ -451,8 +460,6 @@ has no color and size options."""
|
||||||
ax.set_ylabel("%s - %s" % (sel_dim, id_2))
|
ax.set_ylabel("%s - %s" % (sel_dim, id_2))
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
self.canvas = FigureCanvas(fig)
|
|
||||||
self.add(self.canvas)
|
self.add(self.canvas)
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
|
|
||||||
|
@ -531,15 +538,12 @@ class NetworkPlot(Plot):
|
||||||
if kw.has_key('node_color'):
|
if kw.has_key('node_color'):
|
||||||
kw.pop('node_color')
|
kw.pop('node_color')
|
||||||
|
|
||||||
# FIXME: What is figsize?
|
|
||||||
self.fig = Figure(figsize=(5, 4), dpi=72)
|
|
||||||
self.ax = self.fig.add_subplot(111)
|
self.ax = self.fig.add_subplot(111)
|
||||||
# FIXME: ax shouldn't be in kw at all
|
# FIXME: ax shouldn't be in kw at all
|
||||||
if kw.has_key('ax'):
|
if kw.has_key('ax'):
|
||||||
kw.pop('ax')
|
kw.pop('ax')
|
||||||
|
|
||||||
# Add canvas and show
|
# Add canvas and show
|
||||||
self.canvas = FigureCanvas(self.fig)
|
|
||||||
self.add(self.canvas)
|
self.add(self.canvas)
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
|
|
||||||
|
|
Reference in New Issue