Repository: enthought/chaco

Issue:
new markers (star, hexagon...) available in ScatterPlot but not in ColormappedScatterPlot
Hi there,

New ScatterPlot markers as star, hexagon, hexagon2, pentagon and so on are not available with ColormappedScatterPlot.

For instance, if you run Chaco demo example scatter.py in basic/, it works well if you change line
"marker='circle'" by "marker='star'".
But if you run basic/cmap_scatter.py with the same modification, it displays... nothing.

So my question is : could it be possible to implement these new markers in ColormappedScatterPlot please? 

Thanks in advance,

Cheers,

Debian Linux 64bits unstable, Enthought code from git, Python 2.7, wxPython 3.0.2, Chaco 4.7.1.dev45, Traits 4.7.0.dev94 & TraitsUI 6.1.0.dev22


Discussion:
Hi, thanks for the report.  I have a suspicion as to where the issue may be.

Can you try setting `render_method = 'bruteforce'` on the colormapped scatterplot to see if that makes a difference in your case?
Hi Corran,

I tried your hint.
But there is no difference.
Thanks for the feedback - that means that the issue isn't what I thought it might be.
Any news of this issue, please?

Thanks in advance.
Hello all,

Any news about this issue?

Regards

Resolving patch:
diff --git a/chaco/colormapped_scatterplot.py b/chaco/colormapped_scatterplot.py
--- a/chaco/colormapped_scatterplot.py
+++ b/chaco/colormapped_scatterplot.py
@@ -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
                 for i in range(len(x)):
                     gc.set_fill_color(colors[i])
                     gc.draw_path_at_points([[x[i], y[i]]], path, STROKE)


Test patch:
diff --git a/chaco/tests/test_colormapped_scatterplot.py b/chaco/tests/test_colormapped_scatterplot.py
--- a/chaco/tests/test_colormapped_scatterplot.py
+++ b/chaco/tests/test_colormapped_scatterplot.py
@@ -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))