且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何正确地将透视图添加到代表分子的Gnuplot 3D连接的点云中?

更新时间:2023-10-09 11:01:04

嘿.我是一个分子图形学的专家,自1970年代的研究生时代起就开始编写查看器和可视化工具.你知道吗?我真的不喜欢在分子图形学中使用透视图.如此之多,我将gnuplot中的缺失称为功能而不是限制.

Heh. I'm a molecular graphics wonk myself, having written viewers and visualization tools since grad student days in the 1970s. And you know what? I really dislike the use of perspective in molecular graphics. So much so that I'll call the absence in gnuplot a feature rather than a limitation.

gnuplot集合中有一个演示molecule.dem,显示了简单的分子图形.它在gnuplot(5.3)的开发版本中效果更好,在这里您可以对原子使用带有圆圈"而不是带有点"的绘图样式.在这里,您去了:

There is demo molecule.dem in the gnuplot collection showing simple molecular graphics. It works better in the development version of gnuplot (5.3), where you can use plotting style "with circles" rather than "with points" for the atoms. Here you go:

set title "GM1 pentasaccharide ball-and-stick representation"

set hidden3d
set border 0
unset tics
unset key
set title offset 0, screen -0.85
set view equal xyz
set view 348, 163, 1.64872, 1.14

set style fill transparent solid 0.9 border -1
atomcolor(name) = name[1:1] eq "O" ? 0xdd2222 : name [1:1] eq "N" ? 0x4444ff : 0x888888

splot 'GM1_sugar.pdb' using 6:7:8:(0.6):(atomcolor(strcol(3))) with circles fc rgb var, \
      'GM1_bonds.r3d' using 1:2:3:($5-$1):($6-$2):($7-$3) with vectors nohead lw 3 lc "black"

注意:

  • 直接从PDB文件读取原子位置
  • 原子名称产生原子着色(灰色代表碳,蓝色代表氮,等等)
  • 键是通过Raster3D分子图形软件包中的"bonds"实用程序从相同的PDB文件生成的.
  • 前面的原子对后面原子的遮挡是由"set hidden3d"处理的.
  • 键的封闭性不太令人满意,因为线段一直绘制到原子中心,而从视觉上看,终止于原子的投影球面会更好.
  • 通过使原子部分透明,进一步帮助了视觉上的深度印象.
  • The atom positions are read directly from a PDB file
  • Atom coloring is generated from the atom name (gray for carbon, blue for nitrogen, etc)
  • The bonds were generated from the same PDB file by the "bonds" utility in the Raster3D molecular graphics package
  • Occlusion of the atoms in back by the ones in front is handled by "set hidden3d"
  • Occlusion of the bonds is less satisfactory because the line segment is drawn all the way to the atom center whereas visually it would look better to terminate at the projected spherical surface of the atom.
  • Visual impression of depth is further helped by making the atoms partially transparent.