1
1
""" Defines the ColormappedScatterPlot and ColormappedScatterPlotView classes.
4
from __future__ import with_statement
4
6
# Major library imports
5
7
from numpy import argsort, array, concatenate, nonzero, invert, take, \
6
8
isnan, transpose, newaxis, zeros
8
10
# Enthought library imports
9
from enthought.kiva import STROKE
11
from enthought.kiva.constants import STROKE
10
12
from enthought.traits.api import Dict, Enum, Float, Instance
11
13
from enthought.traits.ui.api import Item, RangeEditor
183
185
method = self.render_method
187
188
if method == 'bruteforce' or (not batch_capable):
188
189
self._render_bruteforce(gc, points)
189
190
elif method == 'banded':
190
191
self._render_banded(gc, points)
341
340
alphas = (zeros(len(colors))+self.fill_alpha)[:, newaxis]
342
341
colors = concatenate((colors[:, :3], alphas), axis=1)
346
344
gc.clip_to_rect(self.x, self.y, self.width, self.height)
347
345
gc.set_stroke_color(self.outline_color_)
348
346
gc.set_line_width(self.line_width)
350
marker = self.marker_
348
marker_cls = self.marker_
351
349
size = self.marker_size
352
mode = marker.draw_mode
350
mode = marker_cls.draw_mode
354
if marker != "custom":
352
if marker_cls != "custom":
355
353
if (hasattr(gc, "draw_marker_at_points") and self.marker not in ('custom', 'circle', 'diamond')):
356
draw_func = lambda x, y: gc.draw_marker_at_points([[x,y]], size, marker.kiva_marker)
354
draw_func = lambda x, y: gc.draw_marker_at_points([[x,y]], size, marker_cls.kiva_marker)
358
356
elif hasattr(gc, "draw_path_at_points"):
359
357
path = gc.get_empty_path()
360
358
# turn the class into an instance... we should make add_to_path a
361
359
# class method at some point.
362
marker().add_to_path(path, size)
360
marker_cls().add_to_path(path, size)
363
361
draw_func = lambda x, y: gc.draw_path_at_points([[x,y]], path, mode)
365
gc.translate_ctm(x, y)
367
m.add_to_path(gc, size)
369
gc.translate_ctm(-x, -y)
365
371
for i in range(len(x)):
366
372
gc.set_fill_color(colors[i])
367
373
draw_func(x[i], y[i])
370
path = marker.custom_symbol
376
path = marker_cls.custom_symbol
371
377
for i in range(len(x)):
372
378
gc.set_fill_color(colors[i])
373
379
gc.draw_path_at_points([[x[i], y[i]]], path, STROKE)
378
382
#------------------------------------------------------------------------