出版物质量极坐标图

时间:2017-07-19 16:30:25

标签: python matplotlib plot graph polar-coordinates

我正在尝试制作一个出版品质的极地情节,略微模仿这个情节:

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

我在这里展示的数据有点不同 - 我按交互(N / S / E / W)和交互类型(颜色)排序。我的情节目前看起来很平庸,有没有人有任何极地情节提示?有些事情我可以直接思考,但没有找到解决方案:

1)完全删除N / S / E / W的'ticks'或用45s的刻度替换它们,但是,将图标标记保持在N / S / E / W!

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

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()

0 个答案:

没有答案