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

Color and size per glyph #8

Closed
slinnarsson opened this issue Mar 3, 2017 · 7 comments
Closed

Color and size per glyph #8

slinnarsson opened this issue Mar 3, 2017 · 7 comments

Comments

@slinnarsson
Copy link

This is great!

Feature request for scatter plots: would be fantastic if you could set the color and size of each glyph individually, for visualization of multidimensional scientific data.

@jeammimi
Copy link
Contributor

jeammimi commented Mar 3, 2017

I agree and started to implement it.

@maartenbreddels
Copy link
Collaborator

Thank you, as @jeammimi is saying, he's working on it in #10

@maartenbreddels
Copy link
Collaborator

Fixed by #10 thanks to @jeammimi

@deeptavker
Copy link

Hey, I'm trying to plot a 3D scatter with colorscale. Something like this :
3dscatter

I am using ipyvolume.pylab.scatter but I don;t understand how I can have colors in such fashion, I looked at #10 and tried it using the color option.

A trivial code which follows the idea that I'm using to achieve the above shown image.

import ipyvolume.pylab as p3
import numpy as np

#points
x = np.arange(10)
y = np.arange(10)
z = np.arange(10)

#colors
#For each point x,y,z the color corresponding to the same index in c should be used
c = np.arange(10).astype('float64')/10

p3.clear()
p3.scatter(x, y, z, color=np.meshgrid(range(3),c)[1], size=3)
p3.show()

The output :
sccatter

Can I directly use c without using np.meshgrid() or something similar? Note that I used np.meshgrid just to create an array with required shape. I'm sure there is a cleaner way to do this.
How do I set a colorscale as shown in the first image? And how to add a colorbar legend?

Any help is appreciated, thanks :-)

@maartenbreddels
Copy link
Collaborator

Hi,

maybe #12 would have been useful, but otherwise the code below might help. The idea is to use a matplotlib colormap, that maps to rgb(a) values.

import ipyvolume.pylab as p3
import numpy as np
import matplotlib.cm
#points
x = np.arange(10)
y = np.arange(10)
z = np.arange(10)

#colors
colormap = matplotlib.cm.viridis
c = colormap(np.linspace(0, 1, len(x)))
p3.clear()
p3.scatter(x, y, z, color=c, size=3)
p3.show()

Hope this helps, let me know!

cheers,

Maarten

@deeptavker
Copy link

Hey! This works just fine :)

Yes, I should have looked at #12

Since I probably cannot use pyplot.colorbar for this, I'm still trying to find a way to create legends for multiple scatters on the same cell output display. Anyway, the matplotlib colormap technique works well for the colors.

Thanks a lot!

Although I'm new to this, it's quite simple to use and integrates really well with ipywidgets as compared to matplotlib. Awesome stuff :-)

@maartenbreddels
Copy link
Collaborator

Hi,

thanks!
Indeed, there isn't any colorbar support yet in ipyvolume. You can try to plot that in the same cell using matplotlib, make sure you call pylab.show(), although I've never plotted just a single colorbar it should be possible.

cheers,

Maarten

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

4 participants