Python 可视化原子图 - 如何使用 xyz2graph 将不同的原子种类可视化为不同的颜色?

问题描述 投票:0回答:1

这是我想用xyz2graph可视化的.xyz文件。

18
Atoms. File created from networkx graph by get_decomposition_calc_SRO1.py_edited_by_hand
Ga 0.0 0.0 0.0
In 1.59 0.917986928012 2.583
In 0.0 0.0 5.166
Ga 1.59 0.917986928012 7.749
Ga 0.0 0.0 10.332
Ga 1.59 0.917986928012 12.915
Ga 1.59 2.75396078403 0.0
In 3.18 3.67194771205 2.583
Ga 1.59 2.75396078403 5.166
In 3.18 3.67194771205 7.749
Ga 1.59 2.75396078403 10.332
Ga 3.18 3.67194771205 12.915
Ga 3.18 5.50792156807 0.0
In 4.77 6.42590849608 2.583
In 3.18 5.50792156807 5.166
Ga 4.77 6.42590849608 7.749

这是输出的静态图像:请注意所有的节点(标记为In和Ga的颜色是一样的)。InGaN snippet

用来生成这个图像的代码是直接复制自 本网站:

这里显示的是准确的代码片段。

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)

如何改变化学结构中每个原子的颜色?

python-3.x data-visualization networkx chemistry xyz
1个回答
0
投票

解答

打开软件包,编辑 cpk_colors 词典中 helpers.py 包括原子种类的颜色

为什么呢?

问题在于,无论是铟原子还是镓原子,都没有相关的默认颜色。helpers.py

如果我们检查源码,有两个关键文件。xyz2graph.pyhelpers.py

xyz2graph.py中包含了相关两个原子的共价半径,但helpers.py中没有相关的颜色。cpk_colors 口述

© www.soinside.com 2019 - 2024. All rights reserved.