使用matplotlib(或seaborn)绘制d轨道图 [英] Plotting d orbital diagrams using matplotlib (or seaborn)

查看:249
本文介绍了使用matplotlib(或seaborn)绘制d轨道图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我是化学家,我完成了一个实验,该实验为我提供了金属d轨道的能量.

guys, I'm a chemist and I've finished an experiment that gave me the energies of a metal d orbitals.

在Excel 1 和使用Inkscape之类的绘图程序绘制分子轨道图(就像我在下面 2所做的那样) ),但我很想使用python来获得一个漂亮的图,该图考虑了我在书中看到的轨道能量.

It is relatively easy to get the correct proportion of energies in Excel 1 and use a drawing program like Inkscape to draw the diagram for molecular orbitals (like I did with this one below 2) but I’d love to use python to get a beautiful diagram that considers the energies of my orbitals like we see in the books.

我第一次尝试使用seaborn和swarmplot显然与正确的方法相去甚远,也许(可能是!)不是到达那里的正确方法.我很乐意在 3 中实现右侧的功能.

My first attempt using seaborn and swarmplot is obviously too far from the correct approach and maybe (probably!) is not the correct way to get there. I'd be more than happy to achieve something like the right side here in 3.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

Energies = [-0.40008, -0.39583, -0.38466, -0.23478, -0.21239]
orbitals = ["dz2", "dxy", "dyz", "dx2y2", "dxz"]
df = pd.DataFrame(Energies)
df["Orbitals"] = pd.DataFrame(orbitals)
sns.swarmplot(y=df[0], size=16)

感谢您的帮助.

1 excel

2 使用excel版本作为模型手工绘制

2 Drawn by hand using the excel version as the model

3 从文献中摘录

推荐答案

您可以绘制任何想要从matplotlib中的基本形状和函数派生而来的东西.能级可以是简单的marker s,文本可以由annotate产生.

You can draw anything you like deriving from basic shapes and functions in matplotlib. Energy levels could be simple markers, the texts can be produced by annotate.

import numpy as np
import matplotlib.pyplot as plt


Energies = [-0.40008, -0.39583, -0.38466, -0.23478, -0.21239]
orbitals = ["$d_{z^2}$", "$d_{xy}$", "$d_{yz}$", "$d_{x^2 - y^2}$", "$d_{xz}$"]
x = np.arange(len(Energies))

fig, ax = plt.subplots()
ax.scatter(x, Energies, s=1444, marker="_", linewidth=3, zorder=3)
ax.grid(axis='y')

for xi,yi,tx in zip(x,Energies,orbitals):
    ax.annotate(tx, xy=(xi,yi), xytext=(0,-4), size=18,
                ha="center", va="top", textcoords="offset points")

ax.margins(0.2)
plt.show()

这篇关于使用matplotlib(或seaborn)绘制d轨道图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆