-
Notifications
You must be signed in to change notification settings - Fork 99
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
ScatterPlot example currently shows marker_size takes integer arrays #846
Comments
I can reproduce on macOS. If I change the line marker_size=3, # randint(1,5, numpts), (line 78 of the current demo script) to marker_size=randint(1,5, numpts), and then run the demo script, I get a blank plot, and the following traceback on the console (repeated several times): Traceback (most recent call last):
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/qt4/base_window.py", line 255, in paintEvent
self.handler.paintEvent(event)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/qt4/base_window.py", line 90, in paintEvent
self._enable_window._paint(event)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/abstract_window.py", line 536, in _paint
self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/component.py", line 410, in draw
self._draw(gc, view_bounds, mode)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/component.py", line 781, in _draw
self._dispatch_draw(layer, bb, view_bounds, mode)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/container.py", line 270, in _dispatch_draw
component._dispatch_draw(layer, gc, new_bounds, mode)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/component.py", line 809, in _dispatch_draw
handler(gc, view_bounds, mode)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/chaco/base_xy_plot.py", line 495, in _draw_plot
self._render(gc, pts)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/chaco/plots/scatterplot.py", line 541, in _render
self.render_markers_func(
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/chaco/plots/scatterplot.py", line 191, in render_markers
marker.add_to_path(gc, size)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/markers.py", line 61, in add_to_path
self._add_to_path(path, size)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/enable/markers.py", line 89, in _add_to_path
path.rect(-size, -size, size * 2, size * 2)
File "/Users/mdickinson/.edm/envs/testing/lib/python3.8/site-packages/kiva/agg/agg.py", line 1168, in rect
return _agg.GraphicsContextArray_rect(self, *args)
TypeError: Wrong number or type of arguments for overloaded function 'GraphicsContextArray_rect'.
Possible C/C++ prototypes are:
kiva::graphics_context_base::rect(kiva::rect_type &)
kiva::graphics_context_base::rect(double,double,double,double) |
Yeah, I later find out that my test code was not exactly the same command... I think the solution is adding a check in plot_id() in the Plot class that will convert the int array into float before feeding to class construction |
OK, after looking at the code, I found there is a much better fix: the problem is caused by type mismatch in the ScatterPlot1D class which specifies marker_size as Float. But the function that actually uses this parameter (render_markers_func) is actually designed to handle both single int, float and their numpy arrays (in case of a single numeric input, it will repeat it into an array). So the fix is just change ScatterPlot1D to accept both number and array. I haven't find a Trait type that allows us to do "or". Thus I go with Any for this trait. PR #859 @corranwebster |
Take a look at the |
Thanks Mark! Changed to use union |
Problem Description
ScatterPlot example
scatter_1d
currently showsmarker_size
takes integer arrays as an inputThis will return a typeerror in the Kiva backend.
Reproduction Steps:
Run the
scatter_1d
demo from etsdemo. withmarker_size=randint(1,5, numpts)
Expected behavior:
This should have generated a scatterplot with different sized points.
OS, Python version: [windows, Python3.8]
The text was updated successfully, but these errors were encountered: