diff --git a/system/plots.py b/system/plots.py index 16dbe4a..d74b55d 100644 --- a/system/plots.py +++ b/system/plots.py @@ -225,8 +225,8 @@ class MainView (gtk.Notebook): if focused: self.emit('view-changed', vf) -class Plot (gtk.Frame): +class Plot (gtk.Frame): def __init__(self, title): gtk.Frame.__init__(self) self.sel_obj = None @@ -286,7 +286,6 @@ class EmptyView (Plot): class NavToolbar(NavigationToolbar2): toolitems = (('Select', 'Select within rectangle', 'zoom_to_rect.png', 'select'),) + NavigationToolbar2.toolitems - def __init__(self, *args): NavigationToolbar2.__init__(self, *args) self._select_callback = None @@ -383,12 +382,11 @@ class PlotToolbar(NavToolbar): """ def __init__(self, *args): NavToolbar.__init__(self, *args) - iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR self.tb_freeze = gtk.ToolItem() self.chk = gtk.CheckButton () self.chk.set_label ('Freeze') self.tb_freeze.add (self.chk) - self.tb_freeze.set_tooltip(self.tooltips, 'Freeze current selcetion updating') + self.tb_freeze.set_tooltip(self.tooltips, 'Freeze current selection') self.insert(self.tb_freeze,-1) toolitem = gtk.SeparatorToolItem() self.insert(toolitem, -1) @@ -415,6 +413,7 @@ class LineViewPlot(Plot): self.current_dim = self.dataset.get_dim_name(major_axis) if len(self._data.shape)==2 and not minor_axis: minor_axis = major_axis-1 + #initial draw self.line_collection = {} x_axis = scipy.arrayrange(self._data.shape[minor_axis]) @@ -428,11 +427,8 @@ class LineViewPlot(Plot): self.add(self.canvas) self.canvas.show() - - # We use a regular toolbar as we don't need selections - #self._toolbar = NavigationToolbar2(self.canvas, None) - #self._toolbar.set_property('show-arrow', False) + #FIXME: Lineview plot cannot do selections -> disable in toolbar self._toolbar = PlotToolbar(self.canvas, None) self._toolbar.set_property('show-arrow', False) self._toolbar.chk.connect ('toggled' ,self.set_selection_sensitive) @@ -452,8 +448,8 @@ class LineViewPlot(Plot): 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: @@ -468,9 +464,9 @@ class LineViewPlot(Plot): 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: @@ -481,10 +477,7 @@ class ScatterMarkerPlot(Plot): has no color and size options.""" def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2,s=6, 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 = self.fig.add_subplot(111) 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 @@ -493,18 +486,14 @@ has no color and size options.""" self._selection_line = None x_index = dataset_1[sel_dim][id_1] y_index = dataset_2[sel_dim][id_2] - self.xaxis_data = dataset_1._array[:,x_index] self.yaxis_data = dataset_2._array[:,y_index] - ax.plot(self.xaxis_data,self.yaxis_data,'o',markeredgewidth=0,markersize=s) - ax.set_title(self.get_title()) - #ax.set_xlabel("%s - %s" % (sel_dim, id_1)) - #ax.set_ylabel("%s - %s" % (sel_dim, id_2)) - - ### + self.ax.plot(self.xaxis_data,self.yaxis_data,'o',markeredgewidth=0,markersize=s) + self.ax.set_title(self.get_title()) self.add(self.canvas) self.canvas.show() + # add toolbar self._toolbar = PlotToolbar(self.canvas, None) self._toolbar.chk.connect ('toggled' ,self.set_selection_sensitive) self._toolbar.set_property('show-arrow', False) @@ -526,7 +515,6 @@ has no color and size options.""" assert y1<=y2 index = scipy.nonzero((xdata>x1) & (xdatay1) & (ydata