I have been simulating the interaction of water with different surfaces and would like to plot the Bader charges in an easy to understand way. I successfully used pymatgen bader_analysis_from_objects (as bader_analysis_from_path raised an exception) to generate a structure with Bader charges as a property and I would like to find a way to visualize the result in an easy to understand way. There are two different surfaces (amorphous and crystalline) so while the composition is on average the same, the charges are different. I searching for an effective way to visualize the differences between the two systems.
Hi Paul,
This is a good question. I would recommend a two step process:
-
Ensure that the quantity you want to visualize is attached to the
Structure
via itssite_properties
, e.g.your_struct.add_site_property("charge_difference", [...])
-
Use
Crystal Toolkit
to visualize in a Jupyter notebook. You can use code somewhat like this:
import crystal_toolkit
from crystal_toolkit.core.legend import Legend
legend = Legend(your_struct, color_scheme="name_of_your_site_property")
your_struct.get_scene(legend=legend) # return this in a Jupyter cell to see the atoms color-coded by your site property
Hope this helps!
Matt
Hi Matt,
The few lines you forwarded worked like a charm. I did notice that there was a warning that âColor scheme charge-transfer not available, falling back to Jmol.â This means that Jmol used the colors for the atoms in question, but didnât shade the atom colors by charge-transfer from what I can infer. The interactive nature of the plot is very useful and I can see the charge-transfer in the popup, but it would be nice to vary the colors to indicate this. Is it possible to define a color-scheme to do so? I did look at the documentation for Legend, but other than an on-the-fly color-scheme for color blind users, there wasnât much to go on. It would be nice to be able to draw bonds and the like too, but the documentation is a little hard to follow (e.g. the âYour First Componentâ section dwells on how one should subclass MPComponent, but there is no overview describing why this is necessary. I assume doucmenation is minimal at this point, but are there any (comment?) examples that one could look at to use the crystal_toolkit better?
Paul