-
Notifications
You must be signed in to change notification settings - Fork 98
Use draw_marker_at_points if possible otherwise use draw_path_at_points in ColormappedScatterPlot #672
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
Use draw_marker_at_points if possible otherwise use draw_path_at_points in ColormappedScatterPlot #672
Changes from all commits
c6a1cff
bcf8a13
b9c5beb
7f65424
2013ec0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| ) | ||
|
|
||
| # Enthought library imports | ||
| from kiva.constants import STROKE | ||
| from kiva.api import NO_MARKER, STROKE | ||
| from traits.api import Dict, Enum, Float, Instance, observe | ||
| from traitsui.api import Item, RangeEditor | ||
|
|
||
|
|
@@ -315,11 +315,8 @@ def _render_banded(self, gc, points): | |
|
|
||
| cmap = self.color_mapper | ||
|
|
||
| if hasattr(gc, "draw_marker_at_points") and self.marker not in ( | ||
| "custom", | ||
| "circle", | ||
| "diamond", | ||
| ): | ||
| if hasattr(gc, "draw_marker_at_points") and \ | ||
| (marker.kiva_marker != NO_MARKER): | ||
| # This is the fastest method: we use one of the built-in markers. | ||
| color_bands = cmap.color_bands | ||
| # Initial setup of drawing parameters | ||
|
|
@@ -393,14 +390,10 @@ def _render_bruteforce(self, gc, points): | |
| marker_size = marker_size[self._cached_point_mask] | ||
| mode = marker_cls.draw_mode | ||
|
|
||
| if marker_cls != "custom": | ||
| if self.marker != "custom": | ||
| if hasattr( | ||
| gc, "draw_marker_at_points" | ||
| ) and self.marker not in ( | ||
| "custom", | ||
| "circle", | ||
| "diamond", | ||
| ): | ||
| ) and marker_cls.kiva_marker != NO_MARKER: | ||
| draw_func = lambda x, y, size: gc.draw_marker_at_points( | ||
| [[x, y]], size, marker_cls.kiva_marker | ||
| ) | ||
|
|
@@ -434,7 +427,7 @@ def draw_func(x, y, size): | |
| draw_func(x[i], y[i], size) | ||
|
|
||
| else: | ||
| path = marker_cls.custom_symbol | ||
| path = self.custom_symbol | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| for i in range(len(x)): | ||
| gc.set_fill_color(colors[i]) | ||
| gc.draw_path_at_points([[x[i], y[i]]], path, STROKE) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,3 +86,11 @@ def test_colormap_updated(self): | |
| """ If colormapper updated then we need to redraw """ | ||
| self.color_mapper.updated = True | ||
| self.assertFalse(self.scatterplot.draw_valid) | ||
|
|
||
| # regression test for enthought/chaco#425 | ||
| def test_non_kiva_marker(self): | ||
| self.scatterplot.marker = "star" | ||
|
|
||
| self.gc.render_component(self.scatterplot) | ||
| actual = self.gc.bmp_array[:, :, :] | ||
| self.assertFalse(alltrue(actual == 255)) | ||
|
Comment on lines
+90
to
+96
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was being dumb before, it was trivial to write this regression test...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note this PR also fixes the test |
||
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.
marker_cls is not a string, but the actual class e.g.
<class 'enable.markers.CustomMarker'>