-
Notifications
You must be signed in to change notification settings - Fork 34
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 the 3D structure by a property #303
Conversation
I should note that I've implemented a color_function that includes a check for undefined values (such as when taking the square root of a negative value of the selected property). In such cases, the atom is assigned a gray color. |
Another observation is that IMO we REALLY need to provide a rudimentary color scale, otherwise it's very hard to read the figures. I read a bit and it seems the best way to do this would be to add an HTML entity outside the widget, a bit like the floating buttons in the top-right cornier. |
The idea was to us a custom label, for which we can set the background to an arbitrary HTML canvas, for which doing a gradient would be fairly easy. But let's make sure the core of the functionality works first, merge it and then work on the color bar in a separate PR to reduce the size of the individual PRs. |
Co-Authored-By: Angelo Rossi <[email protected]>
803f1ad
to
b711fc9
Compare
The coloring is now dependent of the selected structure. Added a support of missing properties. Atoms with missing property value are colored in dark gray when the property is selected.
'RWB' should really be bwr
OK I have added an example that generates a simple color-coded figure. I have also renamed the RWB color scheme because it's blue first. I think one important thing is we can do to make it possible to have a reference for the colors is to make sure we have color schemes that match the plotly one. BWR is very similar to seismic (and this I have used in the example) but it'd be nice to have exactly the same schemes - at least viridis and magma for instance. |
Just commenting that this Fixes #118 for good |
This kind of comment needs to be in the first message of the PR for github to automatically close the issue |
python/examples/colors.py
Outdated
for a in frames: | ||
a.arrays["polarizability"] = np.array( | ||
[ | ||
(axx + ayy + azz) / 3 | ||
for (axx, ayy, azz) in zip( | ||
a.arrays["axx"], a.arrays["ayy"], a.arrays["azz"] | ||
) | ||
] | ||
) | ||
|
||
# one possible measure of anisotropy... | ||
a.arrays["alpha_eigenvalues"] = np.array( | ||
[ | ||
np.linalg.eigvalsh([[axx, axy, axz], [axy, ayy, ayz], [axz, ayz, azz]]) | ||
for (axx, ayy, azz, axy, axz, ayz) in zip( | ||
a.arrays["axx"], | ||
a.arrays["ayy"], | ||
a.arrays["azz"], | ||
a.arrays["axy"], | ||
a.arrays["axz"], | ||
a.arrays["ayz"], | ||
) | ||
] | ||
) | ||
|
||
a.arrays["anisotropy"] = ( | ||
a.arrays["alpha_eigenvalues"][:, 2] - a.arrays["alpha_eigenvalues"][:, 0] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this in the "atomic coloring" example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what you mean by that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, I thought it was better to avoid adding new data files, but we need scalar properties to display.
I'll add a comment so it's clear it's not like one needs to do this in order to use the coloring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good to go once CI passes
merged! 🎉 Thanks @MaximeScope and @angerossi for your work implementing this! |
It should finally be possible to merge the coloring of the 3d structure with master.
There is an additional option to color the background atoms by property
=> (Environments -> more options -> color: prop, style: ball and stick)
EDIT:
Fixes #118