xyz2graph is a Python package for reading of .xyz files and constructing of molecular graphs from atomic coordinates. The molecular graph can be converted into NetworkX graph or Plotly figure for 3D visualization in a browser window or in a Jupyter notebook.
python -m pip install git+https://github.com/zotko/xyz2graph.git
from xyz2graph import MolGraph, to_networkx_graph, to_plotly_figure
from plotly.offline import offline
# Create the MolGraph object
mg = MolGraph()
# Read the data from the .xyz file
mg.read_xyz('path/molecule.xyz')
# Create the Plotly figure object
fig = to_plotly_figure(mg)
# Plot the figure
offline.plot(fig)
# Convert the molecular graph to the NetworkX graph
G = to_networkx_graph(mg)
from xyz2graph import MolGraph, to_networkx_graph, to_plotly_figure
from plotly.offline import init_notebook_mode, iplot
# Initiate the Plotly notebook mode
init_notebook_mode(connected=True)
# Create the MolGraph object
mg = MolGraph()
# Read the data from the .xyz file
mg.read_xyz('path/molecule.xyz')
# Create the Plotly figure object
fig = to_plotly_figure(mg)
# Plot the figure
iplot(fig)