Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 13648|回复: 1
打印 上一主题 下一主题

豆粑粑 matlab plot energy profile line

[复制链接]

529

主题

598

帖子

3012

积分

论坛元老

Rank: 8Rank: 8

积分
3012
跳转到指定楼层
楼主
发表于 2020-6-8 13:29:29 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
其实,画能量的拆线,方法很多。

rigin
http://sobereva.com/320

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


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

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

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




  1. clear all
  2. clc
  3. clf


  4. %% outline
  5. % plot the energy profile 4 CHY, who plots the  eng profile manully.
  6. %

  7. x  = [ 1 2 3 4 5 ];
  8. y1 = [0  9.34 -15.06 -4.08 -15.7];
  9. y2 = [0 16.23 -5.49 11.59  -2.72];

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



  12. col ='r';
  13. flg_ud='up';
  14. hold on
  15. [h1]=fun_mm_plot_eng_prof(x,y1,t1,'k','dn')


  16. flg_ud='dn';
  17. [h1]=fun_mm_plot_eng_prof(x,y2,t2,'r','up')
  18. axis equal
  19. set(gca,'fontsize',20,'xtick',[],'ytick',[-20:10:20],'linewidth',2)
  20. axis([5 55 -25 25])


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

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



  26. %% logs
  27. % mod : 2020年 6月 8日 星期一 13时10分15秒 CST
复制代码


fun_mm_plot_eng_prof.m
  1. function [h]=fun_mm_plot_eng_prof(x,y1,t1,col,flg_ud)


  2. n_p = length(y1);
  3. x_thr= 2.6;

  4. for i = 1:n_p
  5.     plot([x(i)*10-x_thr, x(i)*10+x_thr],[y1(i), y1(i)],'-','linewidth',6,'color',col)
  6. end

  7. for i = 1:(n_p-1);
  8.     plot([x(i)*10+x_thr x(i+1)*10-x_thr],[y1(i) y1(i+1)],':','linewidth',2,'color',col)
  9. end


  10. for i = 1:n_p
  11.         if y1(i) > 0
  12.             mm_str{i} = {t1{i};['+',num2str(y1(i),'%6.2f')]};
  13.         elseif y1(i)<0
  14.             mm_str{i} = {t1{i};[num2str(y1(i),'%6.2f')]};
  15.         else
  16.             mm_str{i} = {t1{i};num2str(y1(i))};
  17.         end
  18. end

  19. if flg_ud=='up'
  20.     for i = 1:n_p
  21.         text(x(i)*10-x_thr+0.2,y1(i)+3,mm_str{i},'color',col,'fontsize',14)
  22.     end
  23. else
  24.     for i = 1:n_p
  25.         text(x(i)*10-x_thr+0.2,y1(i)-3,mm_str{i},'color',col,'fontsize',14)
  26.     end
  27. end

  28. h=gcf;
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

529

主题

598

帖子

3012

积分

论坛元老

Rank: 8Rank: 8

积分
3012
沙发
 楼主| 发表于 2020-6-8 13:43:39 | 只看该作者
python版本的,我控制不好,不过效果也 还不错。

  1. unzip PyEnergyDiagrams-master.zip
  2. cd PyEnergyDiagrams-master
  3. python setup.py install
复制代码


或是
  1. pip install git+https://github.com/giacomomarchioro/PyEnergyDiagrams
复制代码



  1. import sys
  2. from energydiagram import ED
  3. import matplotlib.pyplot as plt


  4. diagram = ED()

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


  15. diagram.add_link(0,1)
  16. diagram.add_link(0,2,color='r')
  17. diagram.add_link(1,3)
  18. diagram.add_link(2,4,color='r')

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

  23. diagram.plot(ylabel="Free energy ($Kcal$ $mol^{-1}$)")
复制代码



fig_python_eng_pro.png (15.92 KB, 下载次数: 1326)

fig_python_eng_pro.png

PyEnergyDiagrams-master.zip

82.22 KB, 下载次数: 0

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-4-20 06:42 , Processed in 0.117744 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表