Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Fixed axes scaling error in scatterplot

This commit is contained in:
Arnar Flatberg 2007-12-14 17:27:12 +00:00
parent 4de9a58ae9
commit e80440472d
1 changed files with 21 additions and 5 deletions

View File

@ -406,7 +406,7 @@ class ScatterPlot(Plot):
self._absi = absi self._absi = absi
self._ordi = ordi self._ordi = ordi
if max == None: if max == None:
max=5 max = 5
sb_a = gtk.SpinButton(climb_rate=1) sb_a = gtk.SpinButton(climb_rate=1)
sb_a.set_range(1, max) sb_a.set_range(1, max)
sb_a.set_value(absi+1) sb_a.set_value(absi+1)
@ -429,7 +429,7 @@ class ScatterPlot(Plot):
hbox.pack_start(gtk_label_o) hbox.pack_start(gtk_label_o)
hbox.pack_start(sb_o) hbox.pack_start(sb_o)
self._toolbar.insert(toolitem, -1) 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? self._toolbar.show_all() #do i need this?
def set_absicca(self, sb): def set_absicca(self, sb):
@ -448,7 +448,6 @@ class ScatterPlot(Plot):
def set_ordinate(self, sb): def set_ordinate(self, sb):
self._ordi = sb.get_value_as_int() - 1 self._ordi = sb.get_value_as_int() - 1
xy = self.dataset_1._array[:,[self._absi, self._ordi]] xy = self.dataset_1._array[:,[self._absi, self._ordi]]
#xy = self._T[:,[self._absi, self._ordi]]
self.xaxis_data = xy[:,0] self.xaxis_data = xy[:,0]
self.yaxis_data = xy[:,1] self.yaxis_data = xy[:,1]
self.sc._offsets = xy self.sc._offsets = xy
@ -485,8 +484,6 @@ class ScatterPlot(Plot):
s=self.s, c=self.c, linewidth=lw, s=self.s, c=self.c, linewidth=lw,
zorder=3, **self.kw) zorder=3, **self.kw)
self._mappable = self.sc 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.selection_collection = self.axes.scatter(self.xaxis_data,
self.yaxis_data, self.yaxis_data,
alpha=0, alpha=0,
@ -494,8 +491,27 @@ class ScatterPlot(Plot):
edgecolor='r', edgecolor='r',
linewidth=0, linewidth=0,
zorder=4) 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) 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): def is_mappable_with(self, obj):
"""Returns True if dataset/selection is mappable with this plot. """Returns True if dataset/selection is mappable with this plot.
""" """