Fixed colormap bug
This commit is contained in:
parent
5c2df5c163
commit
07477888bb
|
@ -530,28 +530,46 @@ class ScatterPlot(Plot):
|
|||
else:
|
||||
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)
|
||||
# corresponding indices of input data
|
||||
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)
|
||||
|
||||
# use only values present in scatterplot
|
||||
v = vec[indices]
|
||||
vec_min = min(vec[vec > -scipy.inf])
|
||||
vec_max = max(vec[vec < scipy.inf])
|
||||
v[v==scipy.inf] = vec_max
|
||||
v[v==-scipy.inf] = vec_min
|
||||
ptp = abs(vec_max - 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)
|
||||
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
|
||||
|
||||
# update facecolors
|
||||
self.sc.set_array(map_vec)
|
||||
self.sc.set_clim(vec_min, vec_max)
|
||||
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"):
|
||||
print "changing lut"
|
||||
#! fixme this is just a hack, not even tested
|
||||
lut_l = 1.*self.sc.cmap._lut.shape[0]
|
||||
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]
|
||||
self.sc.cmap._lut[0,:] = [.5,.5,.5,1]
|
||||
else:
|
||||
print "No lut present"
|
||||
self.canvas.draw()
|
||||
|
|
Reference in New Issue