nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories

Home Page:http://nglviewer.org/nglview/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visualizing arrows defined by atoms positions along a trajectory

dpasserone opened this issue · comments

I am able to add arrows to an ASEstructure object, by connecting two atoms at positions c1 and c2.

  def view_structure(structure,myvec=[]):
          t = nv.ASEStructure(structure)
          w = nv.NGLWidget(t, gui=True)
          return w
       
  myview = view_structure(myase_structure)
  c1 = myase_structure.get_positions()[6]
  c2 = myase_structure.get_positions()[5]
  myview.shape.add_arrow(c1,c2,[0,0,0],0.3)
image

How can I do the same with the analogous ASETrajectory, making the arrow recalculating the c1 and c2 positions everytime I change the frame in the GUI?

def view_trajectory(trajectory):
    t2 = nv.ASETrajectory(trajectory)
    w2 = nv.NGLWidget(t2, gui=True)
    return w2;

Thank you!

hi @dpasserone
Unfortunately I don't know the answer yet (not sure if it's possible).