glue-viz / glue-vispy-viewers

3-d data viewers for glue based on VisPy
http://glueviz.org/en/stable/whatsnew/experimental_3d.html#experimental-3d
BSD 2-Clause "Simplified" License
25 stars 21 forks source link

Error when trying to display a 3D scatter plot #156

Closed robintw closed 8 years ago

robintw commented 8 years ago

After reading about this extension in the most recent Glue release email, I wanted to try it out. I installed it as instructed (conda install -c conda-forge glue-vispy-viewers) and tried to create a 3D Scatter Plot viewer using the SPOT_ROI.bsq data file from glue-geospatial, and get the following error:

Traceback (most recent call last):
  File "/Users/robin/code/glue/glue/app/qt/mdi_area.py", line 61, in dropEvent
    new_layer(layer)
  File "/Users/robin/code/glue/glue/app/qt/mdi_area.py", line 51, in new_layer
    self._application.choose_new_data_viewer(layer)
  File "/Users/robin/code/glue/glue/app/qt/application.py", line 672, in choose_new_data_viewer
    return self.do(cmd)
  File "/Users/robin/code/glue/glue/core/application_base.py", line 197, in do
    self._cmds.do(command)
  File "/Users/robin/code/glue/glue/core/command.py", line 126, in do
    result = cmd.do(self._session)
  File "/Users/robin/code/glue/glue/core/command.py", line 216, in do
    v = session.application.new_data_viewer(self.viewer, self.data)
  File "/Users/robin/code/glue/glue/viewers/common/qt/mpl_widget.py", line 38, in wrapper
    result = func(*args, **kwargs)
  File "/Users/robin/code/glue/glue/core/application_base.py", line 75, in new_data_viewer
    if data and not c.add_data(data):
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/scatter/scatter_viewer.py", line 26, in add_data
    self._update_attributes(layer_artist=layer_artist)
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/scatter/scatter_viewer.py", line 58, in _update_attributes
    self._options_widget.z_att)
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/scatter/layer_artist.py", line 172, in set_coordinates
    self._update_data()
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/scatter/layer_artist.py", line 198, in _update_data
    self.redraw()
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/scatter/layer_artist.py", line 125, in redraw
    self._multiscat._update()
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/scatter/multi_scatter.py", line 142, in _update
    self.set_data(data, edge_color=colors, face_color=colors, size=sizes)
  File "/opt/anaconda3/lib/python3.4/site-packages/glue_vispy_viewers/extern/vispy/visuals/markers.py", line 534, in set_data
    pos.ndim == 2 and pos.shape[1] in (2, 3))
AssertionError

Any ideas?

astrofrog commented 8 years ago

@robintw - what is the dimensionality of the data? I think that currently the 3D scatter plot viewer won't work with anything other than 1D components - but we could easily .ravel() on the fly to support N-dimensional components.

robintw commented 8 years ago

Yes, you're right: the data components are all 2D (image data). Automatically doing a ravel() would be great :)

robintw commented 8 years ago

I thought I might knock up a quick PR for this, but I've had a look at the code and I'm not really sure where it is best to stick the ravel() call. It might be easiest for me to leave this to you, if that's ok.

astrofrog commented 8 years ago

Sounds good - I'll make a PR shortly!