Skip to content

FIX: missing color bar when direction flipped#341

Merged
stevenjkern merged 2 commits into
masterfrom
fix/colorbar-reverse
Apr 14, 2017
Merged

FIX: missing color bar when direction flipped#341
stevenjkern merged 2 commits into
masterfrom
fix/colorbar-reverse

Conversation

@stevenjkern
Copy link
Copy Markdown
Contributor

Closes #311. The arange produced an empty array when the direction attribute is set to flipped since mapper.low_pos > mapper.high_pos. This PR tells arange to descend when using the flipped direction rather than ascend. Here is the example from #311 before:
image

and after:
image

Comment thread chaco/color_bar.py Outdated
mapper = self.index_mapper

scrn_points = arange(mapper.low_pos, mapper.high_pos+1)
direction = 1 if self.direction == 'normal' else -1
Copy link
Copy Markdown

@cfarrow cfarrow Feb 28, 2017

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.

Comment thread chaco/color_bar.py Outdated
direction = 1 if self.direction == 'normal' else -1
scrn_points = arange(
mapper.low_pos, mapper.high_pos + 1, direction
)
Copy link
Copy Markdown
Member

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?

@stevenjkern
Copy link
Copy Markdown
Contributor Author

@jwiggins, I think that was covered by the change that @cfarrow suggested. Any further concerns or should I :shipit: ?

@jwiggins
Copy link
Copy Markdown
Member

Sorry, I ran into enthought/enable#266 when I was trying to test this. I've now tested it. LGTM!

@stevenjkern
Copy link
Copy Markdown
Contributor Author

Thanks, @cfarrow and @jwiggins! Merging now.

@stevenjkern stevenjkern merged commit 1e315e0 into master Apr 14, 2017
@stevenjkern stevenjkern deleted the fix/colorbar-reverse branch April 14, 2017 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants