Skip to content
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

Multicolor/size issues #12

Closed
slinnarsson opened this issue Mar 6, 2017 · 4 comments
Closed

Multicolor/size issues #12

slinnarsson opened this issue Mar 6, 2017 · 4 comments

Comments

@slinnarsson
Copy link

slinnarsson commented Mar 6, 2017

Setting colors per datapoint doesn't work:

import ipyvolume
x = np.array([1,2,3,4,5])
y = np.array([2,4,3,2,1])
z = np.array([9,8,3,4,1])
#c = np.array(['red','green','blue','yellow','cyan'])
#c = np.array([(1,1,0), (1,1,0), (1,1,0), (1,1,0), (1,1,0)])
#c = [[1,1,0], [1,1,0],[1,1,0],[1,1,0],[1,1,0]]
c = [1,1,0]
ipyvolume.quickscatter(x, y, z, color=c, size=0.1, marker="sphere")

The result is white spheres in every case.

Also, setting the size doesn't work:

import ipyvolume
x = np.array([1,2,3,4,5])
y = np.array([2,4,3,2,1])
z = np.array([9,8,3,4,1])
s = np.array([1, 2, 3, 4, 5])/10
ipyvolume.quickscatter(x, y, z, color='blue', size=s, marker="sphere")

The result is no spheres at all.

Probably I'm misunderstanding the API, but an example would help.

Finally, I think the case where the color is given as a 1D array of floats should be reserved for a colormap, NOT interpreted as an rgb value. By default, the matplotlib default colormap should be used, or a custom colormap given by the parameter cmap=.

Tagging @jeammimi

@jeammimi
Copy link
Contributor

jeammimi commented Mar 7, 2017

I think both cases were fixed in the last commit
Also try setting the size to 1, because apparently 0.1 is quite small.

@maartenbreddels
Copy link
Collaborator

In the first example, replace size by 10. Initially, size (or s argument) was a fraction of the box size, but since humans aren't that good with numbers between 0 and 1, I switched to percentages, so 100 is the size of the box/volume, 10 is 10% of it. It will be in the changelog for the next release, sorry for this, that's the fate of early adopters I'm afraid ;). For the 2nd example it's the same, try removing the /10. Also, i'm not adopting matplotlib's short argument names (s versus size), since we have tab-completion in the notebook, and that leads to more readable code.

I'm working on examples, stay tuned for the next release.
I agree with you on the colormap.
What is planned for color is these options:

  • shape is 0 dim, and it's a string, interpret as color
  • shape is 1 dim, items are strings, seperate color for each item
  • shape is 2 dim, items are strings, sequence of the above
  • no color scale / colormap is set
  • shape is 1 dim, items are floats, it should be of length 3 -> rgb values (possibly later 4 for opacity)
  • shape is 2 dim, items are float, it should be of shape (len(x), 3) -> rgb values
  • shape is 3 dim, items are float, it should be (sequence_length, len(x), 3) -> rgb values
  • color scale / colormap is set
    • shape is 0 dim, item if float, use the colorscale to map to color
    • shape is 1 dim, it's a seperate color for each item
    • shape is 2 dim, again a sequence

without having a default colormap/colorscale, it will try to interpret it as rgb values, when a colorscale is set, it will use that. For now you have to use matplotlib's colormaps directly (opacity is ignored):

import ipyvolume
import matplotlib.cm
x = np.array([1,2,3,4,5])
y = np.array([2,4,3,2,1])
z = np.array([9,8,3,4,1])
c = matplotlib.cm.afmhot(np.linspace(0, 1, len(x)))
ipyvolume.quickscatter(x, y, z, color=c, size=10, marker="sphere")

I'd like to delay colormap/colorscale in ipyvolume until jupyter-widgets/ipywidgets#1153 takes more shape.

Let me know if this answer your questions.

@slinnarsson
Copy link
Author

Thanks - it works!

@maartenbreddels
Copy link
Collaborator

👍 for letting me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants