From 75203c26cc966852ecac22bb98befc5ebf9b937a Mon Sep 17 00:00:00 2001 From: stevenjkern Date: Tue, 28 Feb 2017 10:17:56 -0600 Subject: [PATCH 1/2] FIX: missing color bar when direction flipped --- chaco/color_bar.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chaco/color_bar.py b/chaco/color_bar.py index dd120b9b8..12cd9049a 100644 --- a/chaco/color_bar.py +++ b/chaco/color_bar.py @@ -140,7 +140,10 @@ def _draw_plot(self, gc, view_bounds=None, mode='normal'): mapper = self.index_mapper - scrn_points = arange(mapper.low_pos, mapper.high_pos+1) + direction = 1 if self.direction == 'normal' else -1 + scrn_points = arange( + mapper.low_pos, mapper.high_pos + 1, direction + ) # Get the data values associated with the list of screen points. if mapper.range.low == mapper.range.high: @@ -149,7 +152,6 @@ def _draw_plot(self, gc, view_bounds=None, mode='normal'): data_points = array([mapper.range.high]) else: data_points = mapper.map_data(scrn_points) - if self.direction == 'flipped': data_points = data_points[::-1] From c9f0d6cc4b2d40bbe0f21d24cc450393ee3583f4 Mon Sep 17 00:00:00 2001 From: stevenjkern Date: Wed, 1 Mar 2017 10:45:49 -0600 Subject: [PATCH 2/2] FIX: better handling of flipped direction --- chaco/color_bar.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/chaco/color_bar.py b/chaco/color_bar.py index 12cd9049a..8aaff3094 100644 --- a/chaco/color_bar.py +++ b/chaco/color_bar.py @@ -140,10 +140,11 @@ def _draw_plot(self, gc, view_bounds=None, mode='normal'): mapper = self.index_mapper - direction = 1 if self.direction == 'normal' else -1 - scrn_points = arange( - mapper.low_pos, mapper.high_pos + 1, direction - ) + low = mapper.low_pos + high = mapper.high_pos + if self.direction == 'flipped': + low, high = high, low + scrn_points = arange(low, high + 1) # Get the data values associated with the list of screen points. if mapper.range.low == mapper.range.high: @@ -152,8 +153,6 @@ def _draw_plot(self, gc, view_bounds=None, mode='normal'): data_points = array([mapper.range.high]) else: data_points = mapper.map_data(scrn_points) - if self.direction == 'flipped': - data_points = data_points[::-1] # Get the colors associated with the data points. colors = self.color_mapper.map_screen(data_points)