fixes
This commit is contained in:
@@ -238,6 +238,7 @@ class Plot (gtk.Frame):
|
||||
self.fig = Figure(figsize=(5,4), dpi=72)
|
||||
self.canvas = FigureCanvas(self.fig)
|
||||
self.fig.set_facecolor('white')
|
||||
|
||||
def get_title(self):
|
||||
return self.title
|
||||
|
||||
@@ -394,6 +395,8 @@ class LineViewPlot(Plot):
|
||||
ps: slow (cant get linecollection and blit to work)
|
||||
"""
|
||||
def __init__(self, dataset,major_axis=1,minor_axis=None, name="Line view"):
|
||||
self.use_blit = False
|
||||
self._last_index = []
|
||||
self._data = dataset.asarray()
|
||||
self.dataset = dataset
|
||||
Plot.__init__(self, name)
|
||||
@@ -407,7 +410,10 @@ class LineViewPlot(Plot):
|
||||
x_axis = scipy.arrayrange(self._data.shape[minor_axis])
|
||||
for i in range(self._data.shape[major_axis]):
|
||||
yi = scipy.take(self._data,[i],axis=major_axis)
|
||||
l, = self.ax.plot(x_axis,yi,'k',alpha=.05,animated=True)
|
||||
if self.use_blit:
|
||||
l,=self.ax.plot(x_axis,yi,'k',alpha=.05,animated=True)
|
||||
else:
|
||||
l,=self.ax.plot(x_axis,yi,'k',alpha=.05)
|
||||
self.line_collection[i] = l
|
||||
|
||||
self.add(self.canvas)
|
||||
@@ -427,18 +433,33 @@ class LineViewPlot(Plot):
|
||||
def selection_changed(self, selection):
|
||||
ids = selection[self.current_dim] # current identifiers
|
||||
index = self.dataset.get_indices(self.current_dim, ids)
|
||||
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)
|
||||
if self.use_blit:
|
||||
if self._background is None:
|
||||
self._last_index = None
|
||||
self._background = self.canvas.copy_from_bbox(self.ax.bbox)
|
||||
|
||||
self.canvas.restore_region(self._background)
|
||||
if index:
|
||||
if self._last_index:
|
||||
for i in self._last_index:
|
||||
# if not using blit: reset last selection
|
||||
self.ax.lines[i].set_color('k')
|
||||
self.ax.lines[i].set_alpha(.05)
|
||||
self.ax.lines[i].set_zorder(1)
|
||||
for i in index:
|
||||
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.canvas.blit()
|
||||
self.ax.lines[i].set_color('r')
|
||||
self.ax.lines[i].set_alpha(1.0)
|
||||
self.ax.lines[i].set_visible(True)
|
||||
self.ax.lines[i].set_zorder(3)
|
||||
if self.use_blit:
|
||||
self.ax.draw_artist(self.ax.lines[i])
|
||||
#else:
|
||||
# self.ax.add_line(self.line_collection[i])
|
||||
self._last_index = index
|
||||
if self.use_blit:
|
||||
self.canvas.blit()
|
||||
else:
|
||||
self.canvas.draw()
|
||||
|
||||
class ScatterMarkerPlot(Plot):
|
||||
"""The ScatterMarkerPlot is faster than regular scatterplot, but
|
||||
@@ -446,9 +467,14 @@ has no color and size options."""
|
||||
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2, name="Scatter plot"):
|
||||
Plot.__init__(self, name)
|
||||
self.ax = ax = self.fig.add_subplot(111)
|
||||
#self.ax.set_position([0.01,0.01,.99,.99])
|
||||
self.ax.set_xticks([])
|
||||
self.ax.set_yticks([])
|
||||
self.ax.axhline(0,color='k',lw=1.5,zorder=0)
|
||||
self.ax.axvline(0,color='k',lw=1.5,zorder=0)
|
||||
self.current_dim = id_dim
|
||||
self.dataset_1 = dataset_1
|
||||
|
||||
self._selection_line = None
|
||||
x_index = dataset_1[sel_dim][id_1]
|
||||
y_index = dataset_2[sel_dim][id_2]
|
||||
|
||||
@@ -493,9 +519,9 @@ has no color and size options."""
|
||||
xdata_new = scipy.take(self.xaxis_data, index) #take data
|
||||
ydata_new = scipy.take(self.yaxis_data, index)
|
||||
#remove old selection
|
||||
if len(self.ax.lines)>1:
|
||||
del self.ax.lines[-1]
|
||||
self.ax.plot(xdata_new,ydata_new,'ok')
|
||||
if self._selection_line:
|
||||
self.ax.lines.remove(self._selection_line)
|
||||
self._selection_line, = self.ax.plot(xdata_new,ydata_new,'or')
|
||||
self._toolbar.forward() #update data lims before draw
|
||||
self.canvas.draw()
|
||||
|
||||
@@ -505,6 +531,7 @@ has no color and size options."""
|
||||
def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2,c='b',s=30, name="Scatter plot"):
|
||||
Plot.__init__(self, name)
|
||||
self.ax = ax = self.fig.add_subplot(111)
|
||||
#self.ax.set_position([0.01,0.01,.99,.99])
|
||||
self.current_dim = id_dim
|
||||
self.dataset_1 = dataset_1
|
||||
|
||||
@@ -516,8 +543,8 @@ has no color and size options."""
|
||||
|
||||
ax.scatter(self.xaxis_data,self.yaxis_data,s=s,c=c,faceted=False,edgecolor='k')
|
||||
ax.set_title(self.get_title())
|
||||
ax.set_xlabel("%s - %s" % (sel_dim, id_1))
|
||||
ax.set_ylabel("%s - %s" % (sel_dim, id_2))
|
||||
#ax.set_xlabel("%s - %s" % (sel_dim, id_1))
|
||||
#ax.set_ylabel("%s - %s" % (sel_dim, id_2))
|
||||
|
||||
# collection
|
||||
self.coll = ax.collections[0]
|
||||
@@ -553,8 +580,10 @@ has no color and size options."""
|
||||
ids = selection[self.current_dim] # current identifiers
|
||||
index = self.dataset_1.get_indices(self.current_dim, ids)
|
||||
lw = scipy.zeros(self.xaxis_data.shape,'f')
|
||||
zo = lw.copy() + 1 #z-order
|
||||
scipy.put(lw,index,2.)
|
||||
self.coll.set_linewidth(lw)
|
||||
self.coll.set_zorder(zo)
|
||||
self._toolbar.forward() #update data lims before draw
|
||||
self.canvas.draw()
|
||||
|
||||
@@ -598,6 +627,9 @@ class NetworkPlot(Plot):
|
||||
kw.pop('node_color')
|
||||
|
||||
self.ax = self.fig.add_subplot(111)
|
||||
self.ax.set_position([0.01,0.01,.99,.99])
|
||||
self.ax.set_xticks([])
|
||||
self.ax.set_yticks([])
|
||||
# FIXME: ax shouldn't be in kw at all
|
||||
if kw.has_key('ax'):
|
||||
kw.pop('ax')
|
||||
@@ -659,7 +691,7 @@ class NetworkPlot(Plot):
|
||||
self.ax.clear()
|
||||
networkx.draw_networkx_edges(self.graph, edge_list=self.graph.edges(), \
|
||||
ax=self.ax, **self.keywords)
|
||||
|
||||
networkx.draw_networkx_labels(self.graph,**self.keywords)
|
||||
if unselected_nodes:
|
||||
networkx.draw_networkx_nodes(self.graph, nodelist=unselected_nodes, \
|
||||
node_color='r', node_size=unselected_sizes, ax=self.ax, **self.keywords)
|
||||
|
Reference in New Issue
Block a user