If i import a .xyz file in Mathematica that will show me the moelcule in the default way. But i want to visualise the .xyz file in the following manner.
Answer
Sticks and balls
file = "ben.xyz";
atm = Import[file, "VertexTypes"];
xyz = Import[file];
coord = xyz[[1, 4, 1]];
balls = Cases[xyz[[1, 4, 2]], Sphere[x_, y_] -> {x, y}];
sticks= Cases[xyz[[1, 4, 2]], Cylinder[x_, y_] -> {x, y}];
Graphics[{EdgeForm[Black], FaceForm[White],
{Thickness[#[[2]]/1000], Line[coord[[#[[1]]]][[All, 1 ;; 2]]]} & /@ sticks,
{Disk[coord[[#[[1]]]][[1 ;; 2]], #[[2]]]} & /@ balls,
Text[Style[atm[[#]], 20, Bold], coord[[#, 1 ;; 2]]] & /@ Range[Length[atm]]}]
Comments
Post a Comment