lab-cosmo / chemiscope

An interactive structure/property explorer for materials and molecules
http://chemiscope.org
BSD 3-Clause "New" or "Revised" License
131 stars 32 forks source link

Color atoms by property #229

Closed ceriottm closed 10 months ago

ceriottm commented 2 years ago

Would be interesting to have the possibility of coloring atoms by an atomic property. The option could be active any time there are environment properties defined, and it could use same color schemes as for the map.

jduerholt commented 2 years ago

Yeah, very good idea. I had the same one and I just wanted to open an issue for this ;)

ceriottm commented 2 years ago

@jduerholt Want to help?

jduerholt commented 2 years ago

@Luthaf knows about my very limited java script capabilities ;) Perhaps he can give a bit advise how to actually implement it and then we can see what I can actually contribute ;)

Luthaf commented 2 years ago

This would require a bit of work to (1) get the color associated with the value of the property, through Plotly (we don't really want to re-implement color interpolation from the colormap); (2) use these colors with 3Dmol.js to set the color of atoms one by one and (3) link everything up properly so that the colors are updated whenever the user changes which point is being visualized, the color map or the color range.

I don't know if there is an API for (1) (maybe we can query the color of the point after plotting it?); for (2) we should be able to override the color of the atoms in 3Dmol with atom.color.

This feature would touch quite a lot of different places in the code, I'm happy to guide you around but this might not be the best first point of entry 😃

jduerholt commented 2 years ago

Hi Guillaume,

sorry for my late response, I was travelling ;) This indeed sounds like not best entry point also with respect to my limited java script knowledge. Nevertheless, I am very interested in this feature as this could be really powerful in some scenarios.

Best,

Johannes

ceriottm commented 10 months ago

Implemented through #312 (and previous PRs)