-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: missing color bar when direction flipped #341
Conversation
chaco/color_bar.py
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not do the right thing for flipped bounds. For example, for
low_pos = 1
high_pos = -1
this gives
array([1])
I suggest,
low = mapper.low_pos
high = mapper.high_pos
if self.direction == 'flipped':
low, high = high, low
scrn_points = arange(low, high + 1)
and then delete lines 155-156, which would undo the bounds flip.
chaco/color_bar.py
Outdated
direction = 1 if self.direction == 'normal' else -1 | ||
scrn_points = arange( | ||
mapper.low_pos, mapper.high_pos + 1, direction | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the mapper.high_pos + 1
bit? Won't that need to change when the direction is flipped as well?
Sorry, I ran into enthought/enable#266 when I was trying to test this. I've now tested it. LGTM! |
Closes #311. The

arange
produced an empty array when thedirection
attribute is set toflipped
sincemapper.low_pos > mapper.high_pos
. This PR tellsarange
to descend when using theflipped
direction rather than ascend. Here is the example from #311 before:and after:
