Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions chaco/colormapped_scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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":
Copy link
Copy Markdown
Contributor Author

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'>

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
)
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom_symbol is a trait on the ColormappedScatterPlot, not the marker. For example use, see test test_scatter_custom.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom_symbol is a trait on the ColormappedScatterPlot, not the marker. For example use, see test test_scatter_custom.

for i in range(len(x)):
gc.set_fill_color(colors[i])
gc.draw_path_at_points([[x[i], y[i]]], path, STROKE)
Expand Down
8 changes: 8 additions & 0 deletions chaco/tests/test_colormapped_scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this PR also fixes the test test_scatter_custom above once enthought/enable#782 is pushed through that test can be unskipped.