Fixed colormap bug
This commit is contained in:
parent
5c2df5c163
commit
07477888bb
|
@ -418,7 +418,7 @@ class ScatterPlot(Plot):
|
||||||
sb_o.set_increments(1, 5)
|
sb_o.set_increments(1, 5)
|
||||||
sb_o.connect('value_changed', self.set_ordinate)
|
sb_o.connect('value_changed', self.set_ordinate)
|
||||||
hbox = gtk.HBox()
|
hbox = gtk.HBox()
|
||||||
gtk_label_a = gtk.Label("A:")
|
gtk_label_a = gtk.Label(" A:")
|
||||||
gtk_label_o = gtk.Label(" O:")
|
gtk_label_o = gtk.Label(" O:")
|
||||||
toolitem = gtk.ToolItem()
|
toolitem = gtk.ToolItem()
|
||||||
toolitem.set_expand(False)
|
toolitem.set_expand(False)
|
||||||
|
@ -530,28 +530,46 @@ class ScatterPlot(Plot):
|
||||||
else:
|
else:
|
||||||
vec = array.ravel()
|
vec = array.ravel()
|
||||||
|
|
||||||
|
# 1.) Set all ids present in plot but not in dataset to gray
|
||||||
|
# 2.) Set all ids which are inf/-inf/nan in dataset to gray
|
||||||
|
|
||||||
|
# ids of scatterplot
|
||||||
identifiers = self.dataset_1.get_identifiers(self.current_dim, sorted=True)
|
identifiers = self.dataset_1.get_identifiers(self.current_dim, sorted=True)
|
||||||
|
# corresponding indices of input data
|
||||||
indices = data.get_indices(self.current_dim, identifiers)
|
indices = data.get_indices(self.current_dim, identifiers)
|
||||||
|
# ids of scatterplot that is present in input data
|
||||||
existing_ids = data.existing_identifiers(self.current_dim, identifiers)
|
existing_ids = data.existing_identifiers(self.current_dim, identifiers)
|
||||||
|
|
||||||
|
# use only values present in scatterplot
|
||||||
v = vec[indices]
|
v = vec[indices]
|
||||||
vec_min = min(vec[vec > -scipy.inf])
|
vec_min = min(vec[vec > -scipy.inf])
|
||||||
vec_max = max(vec[vec < scipy.inf])
|
vec_max = max(vec[vec < scipy.inf])
|
||||||
v[v==scipy.inf] = vec_max
|
ptp = abs(vec_max - vec_min)
|
||||||
v[v==-scipy.inf] = vec_min
|
# set all infs equal to max value + delta
|
||||||
|
delta = 2.
|
||||||
|
v[v==scipy.inf] = vec_max + delta
|
||||||
|
v[v==-scipy.inf] = vec_max + delta
|
||||||
|
v[v==scipy.nan] = vec_max + delta
|
||||||
|
|
||||||
|
# get the indices of scatterplot ids present in input data
|
||||||
indices = self.dataset_1.get_indices(self.current_dim, existing_ids)
|
indices = self.dataset_1.get_indices(self.current_dim, existing_ids)
|
||||||
map_vec = vec_min*scipy.ones(len(identifiers))
|
map_vec = vec_max*scipy.ones(len(identifiers))
|
||||||
|
# setting all present values to v
|
||||||
map_vec[indices] = v
|
map_vec[indices] = v
|
||||||
|
|
||||||
# update facecolors
|
# update facecolors
|
||||||
self.sc.set_array(map_vec)
|
self.sc.set_array(map_vec)
|
||||||
self.sc.set_clim(vec_min, vec_max)
|
self.sc.set_clim(vec_min, vec_max)
|
||||||
self.sc.update_scalarmappable() #sets facecolors from array
|
self.sc.update_scalarmappable() #sets facecolors from array
|
||||||
|
# adjust max values so they get one (1) bin in lut
|
||||||
|
|
||||||
if hasattr(self.sc.cmap, "_lut"):
|
if hasattr(self.sc.cmap, "_lut"):
|
||||||
print "changing lut"
|
#! fixme this is just a hack, not even tested
|
||||||
self.sc.cmap._lut[-1,:] = [.5,.5,.5,1]
|
lut_l = 1.*self.sc.cmap._lut.shape[0]
|
||||||
self.sc.cmap._lut[0,:] = [.5,.5,.5,1]
|
map_vec_range = map_vec.ptp()
|
||||||
|
delta_lut = map_vec_range/lut_l
|
||||||
|
map_vec[vec_max + delta] = vec_max + delta_lut/2.
|
||||||
|
self.sc.cmap._lut[-1,:] = [.5, .5, .5, 1]
|
||||||
else:
|
else:
|
||||||
print "No lut present"
|
print "No lut present"
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
Reference in New Issue