meatball1982 发表于 2020-6-8 13:29:29

豆粑粑 matlab plot energy profile line

其实,画能量的拆线,方法很多。

rigin
http://sobereva.com/320

其它工具
http://bbs.keinsci.com/thread-9256-1-1.html


python
https://github.com/giacomomarchioro/PyEnergyDiagrams

效果都不错,只是这种线,不用matlab画一下,总感觉不舒服。

其实,具体的,就是分一小段线,一些字,分开画 。
通过设置字体的位置大小来进行标注。




clear all
clc
clf


%% outline
% plot the energy profile 4 CHY, who plots theeng profile manully.
%

x= [ 1 2 3 4 5 ];
y1 = ;
y2 = ;

t2 ={'R''','TS1''','I1''','TS2''','P'''};
t1 ={'R','TS1','I1','TS2','P'};



col ='r';
flg_ud='up';
hold on
=fun_mm_plot_eng_prof(x,y1,t1,'k','dn')


flg_ud='dn';
=fun_mm_plot_eng_prof(x,y2,t2,'r','up')
axis equal
set(gca,'fontsize',20,'xtick',[],'ytick',[-20:10:20],'linewidth',2)
axis()


ylabel('Free energy (Kcal/mol)')
xlabel('Reaction coordinate')

h=gcf;
fig_na = '../file_imgs/fig_eng_pro';
%fun_work_li_035_myfig_out(h,fig_na,3);



%% logs
% mod : 2020年 6月 8日 星期一 13时10分15秒 CST


fun_mm_plot_eng_prof.m
function =fun_mm_plot_eng_prof(x,y1,t1,col,flg_ud)


n_p = length(y1);
x_thr= 2.6;

for i = 1:n_p
    plot(,,'-','linewidth',6,'color',col)
end

for i = 1:(n_p-1);
    plot(,,':','linewidth',2,'color',col)
end


for i = 1:n_p
      if y1(i) > 0
            mm_str{i} = {t1{i};['+',num2str(y1(i),'%6.2f')]};
      elseif y1(i)<0
            mm_str{i} = {t1{i};};
      else
            mm_str{i} = {t1{i};num2str(y1(i))};
      end
end

if flg_ud=='up'
    for i = 1:n_p
      text(x(i)*10-x_thr+0.2,y1(i)+3,mm_str{i},'color',col,'fontsize',14)
    end
else
    for i = 1:n_p
      text(x(i)*10-x_thr+0.2,y1(i)-3,mm_str{i},'color',col,'fontsize',14)
    end
end

h=gcf;

meatball1982 发表于 2020-6-8 13:43:39

python版本的,我控制不好,不过效果也 还不错。

unzip PyEnergyDiagrams-master.zip
cd PyEnergyDiagrams-master
python setup.py install

或是
pip install git+https://github.com/giacomomarchioro/PyEnergyDiagrams



import sys
from energydiagram import ED
import matplotlib.pyplot as plt


diagram = ED()

diagram.add_level(0,'R(R\')')          #. 0
#diagram.add_level(0.2,'R\'','last',color='r')          #. 0
diagram.add_level(+9.34,'TS1')    #. 1
diagram.add_level(+16.23,'TS1\'','last',color='r') #. 5
diagram.add_level(-15.06,'I1')    #. 2
diagram.add_level(-5.49,'I1\'','last',color='r')    #. 6
diagram.add_level(-4.08,'IS2')    #. 3
diagram.add_level(+11.59,'IS2\'','last',color='r')    #. 7
diagram.add_level(-15.70,'P')   #. 4
diagram.add_level(-2.72,'P\'','last',color='r')   #. 8


diagram.add_link(0,1)
diagram.add_link(0,2,color='r')
diagram.add_link(1,3)
diagram.add_link(2,4,color='r')

diagram.add_link(3,5)
diagram.add_link(4,6,color='r')
diagram.add_link(5,7)
diagram.add_link(6,8,color='r')

diagram.plot(ylabel="Free energy ($Kcal$ $mol^{-1}$)")


页: [1]
查看完整版本: 豆粑粑 matlab plot energy profile line