chemiscope icon indicating copy to clipboard operation
chemiscope copied to clipboard

Color atoms by property

Open ceriottm opened this issue 2 years ago • 5 comments

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.

ceriottm avatar Mar 14 '22 09:03 ceriottm

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

jduerholt avatar Mar 15 '22 14:03 jduerholt

@jduerholt Want to help?

ceriottm avatar Mar 15 '22 16:03 ceriottm

@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 ;)

jduerholt avatar Mar 16 '22 01:03 jduerholt

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 😃

Luthaf avatar Mar 17 '22 14:03 Luthaf

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

jduerholt avatar Mar 22 '22 20:03 jduerholt

Implemented through #312 (and previous PRs)

ceriottm avatar Dec 01 '23 00:12 ceriottm