diff --git a/fluents/plots.py b/fluents/plots.py index efaff65..fd7416d 100644 --- a/fluents/plots.py +++ b/fluents/plots.py @@ -406,7 +406,7 @@ class ScatterPlot(Plot): self._absi = absi self._ordi = ordi if max == None: - max=5 + max = 5 sb_a = gtk.SpinButton(climb_rate=1) sb_a.set_range(1, max) sb_a.set_value(absi+1) @@ -429,7 +429,7 @@ class ScatterPlot(Plot): hbox.pack_start(gtk_label_o) hbox.pack_start(sb_o) self._toolbar.insert(toolitem, -1) - toolitem.set_tooltip(self._toolbar.tooltips, "Set Principal component") + toolitem.set_tooltip(self._toolbar.tooltips, "Set axis") self._toolbar.show_all() #do i need this? def set_absicca(self, sb): @@ -448,7 +448,6 @@ class ScatterPlot(Plot): def set_ordinate(self, sb): self._ordi = sb.get_value_as_int() - 1 xy = self.dataset_1._array[:,[self._absi, self._ordi]] - #xy = self._T[:,[self._absi, self._ordi]] self.xaxis_data = xy[:,0] self.yaxis_data = xy[:,1] self.sc._offsets = xy @@ -485,8 +484,6 @@ class ScatterPlot(Plot): s=self.s, c=self.c, linewidth=lw, zorder=3, **self.kw) self._mappable = self.sc - 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, self.yaxis_data, alpha=0, @@ -494,7 +491,26 @@ class ScatterPlot(Plot): edgecolor='r', linewidth=0, zorder=4) + self.axes.axhline(0, color='k', lw=1., zorder=1) + self.axes.axvline(0, color='k', lw=1., zorder=1) + # axhline and axvline mistakes the max/min using *all* data + self._reset_limits(0) + self._reset_limits(1) + self._background = self.canvas.copy_from_bbox(self.axes.bbox) + + def _reset_limits(self, axis): + if axis == 0: + cax = self.xaxis_data + set_lim = self.axes.set_xlim + elif axis == 1: + set_lim = self.axes.set_ylim + cax = self.yaxis_data + else: + raise ValueError("Axis needs to be 0 or 1") + pad = abs(cax.min()- cax.max())*0.05 + new_lims = (cax.min() - pad, cax.max() + pad) + set_lim(new_lims, emit=True) def is_mappable_with(self, obj): """Returns True if dataset/selection is mappable with this plot.