创建旋转分子的平滑gif

molgif的Python项目详细描述


molgif

创建旋转分子的平滑gif

示例

使用自动旋转找到最佳视角

import molgif
import ase.build

# load in molecule (ase.Atoms object)
molecule = ase.build.molecule('biphenyl')

# create rotating gif with rot_gif function
molgif.rot_gif(molecule, auto_rotate=True)

添加图例

molgif.rot_gif(molecule, add_legend=True)

指定每个原子的颜色

# can be a string for one color or a list of custom colors
rainbow = ['red', 'orange', 'yellow',
           'green', 'blue', 'violet'] * 4

# list much match number of atoms
rainbow = rainbow[:len(molecule)]

molgif.rot_gif(molecule, colors=rainbow)

使用字典按原子类型快速着色

# default colors will be used for types not specified
molgif.rot_gif(molecule, colors=dict(C='hotpink'),
               add_legend=True)

把原子固定在旋转中心

# define index of atom to anchor
anchor = 3

colors = ['white'] * len(molecule)
colors[anchor] = '#0892d0'

molgif.rot_gif(molecule, colors=colors,
               anchor=anchor)

调整循环时间和fps

# loop_time = time to complete one rotation (seconds)
molgif.rot_gif(molecule, loop_time=2, fps=60)

关闭键和标度原子大小

molgif.rot_gif(molecule, add_bonds=False,
               scale=0.9)
< H3>改变旋转轴< EH3>
# switch between x, y (Default), or z
molgif.rot_gif(molecule, rot_axis='z')

开关旋转方向

# counterclockwise (ccw)[Default] or clockwise (cw)
# based on rot_axis
# 'x': view from left
# 'y': view from top
# 'z': view into screen
molgif.rot_gif(molecule, direction='cw')

可视化费用

import random

# random charges [-1, 1]
chgs = [-1 + 2 * random.random() for i in molecule]

# manually set the colorbar range (optional)
cb_range = (-1, 1)

molecule.set_initial_charges(chgs)

molgif.rot_gif(molecule, use_charges=True,
               cb_range=cb_range)

要求

  • ase
  • matplotlib
  • imagemagick(必须安装命令行工具)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
将中心面板添加到“我的内容”窗格时,java GUI对象消失   java无法更新oracle中的clob字段   php Linux+动态插入的Java小程序=在NPObject上调用方法时出错   java JVisualVM探查器代理jar已加载,但代理初始化失败   java Android在运算符和TextView值方面存在问题   用于OpenPGP智能卡小程序的rsa解密APDU   Java GUI按钮不会添加到面板中   java找不到移动图像(或其他可单击对象)的方法   java中Do/While循环的问题   多线程使java程序在没有线程的情况下休眠   java如何在Webflux功能端点的测试中禁用Spring安全性   如果存在后退历史记录,则java WebView仅显示后退按钮   通过USB将Arduino中显示的java错误数据传输到Android   java如何使用安卓 studio从4层父节点firebase获取子节点数据   jpanel中JLabel的java搜索栏   来自gallery/camera的java Android图像预览不同