出版物质量极坐标图图

2024-09-28 21:36:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试制作一个出版物质量的极坐标图,它稍微模仿了这个图:

https://www.nature.com/articles/srep34736/figures/3

我在这里显示的数据有点不同——我按交互(N/S/E/W)和交互类型(颜色)进行排序。我的情节现在看起来很平庸,有没有人有什么偏振光技巧?有些事情我可以直接想到,但还没有找到解决办法:

1)删除N/S/E/W上的“勾号”,要么全部删除,要么用45s上的勾号替换,但是要保持N/S/E/W上的打印标签!在

2)当数据与标签重叠时,能够自定义θ标签的显示位置

3)更漂亮的颜色和在图形上的实现?在

4)将最外层圆的形状改为规则的八角形或其他有n边的形状?在

#Bobby Hollingsworth, VTech/Harvard University
#Bevan-Brown Lab, VTech Department of Biochemistry

import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.pyplot import figure, show, rc

############################################################
#User Input

#Total number of frames analyzed
frames = 2501.0

#Ener Data for residue 1
resname1 = 'D'
backbone1 = 0
hbond1 = 0
polar1 = 78
hydrophobic1 = 0
aromatic1 = 0

#Ener Data for residue 2
resname2 = 'S'
backbone2 = 776
hbond2 = 1000
polar2 = 2418
hydrophobic2 = 0
aromatic2 = 0

#Ener Data for residue 3
resname3 = 'N'
backbone3 = 1439
hbond3 = 688
polar3 =  1000
hydrophobic3 = 0
aromatic3 = 0

#Ener Data for residue 4
resname4 = 'G'
backbone4 = 2335
hbond4 = 932
polar4 = 0
hydrophobic4 = 0
aromatic4 = 0

####################################################

b1 = backbone1/frames
hb1 = hbond1/frames
p1 = polar1/frames
hy1 = hydrophobic1/frames
a1 = aromatic1/frames


b2 = backbone2/frames
hb2 = hbond2/frames
p2 = polar2/frames
hy2 = hydrophobic2/frames
a2 = aromatic2/frames

b3 = backbone3/frames
hb3 = hbond3/frames
p3 = polar3/frames
hy3 = hydrophobic3/frames
a3 = aromatic3/frames

b4 = backbone4/frames
hb4 = hbond4/frames
p4 = polar4/frames
hy4 = hydrophobic4/frames
a4 = aromatic4/frames

######################################################
#Graph settings

#Figure Size and positioning of labels on axes
fig = figure(figsize=(8,8))
ax = fig.add_axes([.1, .1, 0.8, 0.8], polar=True)

N = 24
theta = np.arange(0.0, 2*np.pi, 2*np.pi/N)

#Radii and width of each individual slice
radii = [b1, hy1, a1, 0, hb2, p2, b2, hy2, a2, 0, hb3, p3, b3, hy3, a3, 0, hb4, p4, b4, hy3, a4, 0, hb1, p1]
width = 2*np.pi/N

#X and Y tick size

rc('xtick', labelsize=15)
rc('ytick', labelsize=15)
ax.yaxis.set_ticks([0.2,0.4,0.6,0.8,1])
ax.yaxis.set_ticklabels(['0.2','0.4','0.6','0.8',''])
ax.xaxis.set_ticks([np.pi/4, 3*np.pi/4, 5*np.pi/4, 7*np.pi/4])
#ax.xaxis.set_ticks([0, np.pi/2, np.pi, 3*np.pi/2])
#ax.xaxis.set_ticklabels([resname1,resname2,resname3,resname4])
ax.xaxis.set_ticklabels(['','','',''])
ax.grid(color='black', linestyle='-', linewidth=0.2)

#FIX COLORATION, ODD AXIS, ODD LABELS, THEN DONE!
bars = ax.bar(theta, radii, width=width, bottom=0.0,  color=['#003366', '#CCCC99', '#666699', 'white', '#808080', '#666699'], alpha=.7)

show()

Tags: ofimportfordataframesasnppi