MeteoInfoLab脚本示例:LaTeX写数学公式

LaTeX是排版常用的语法,科学计算软件中也常用它来写数学公式(比如MatLab, Matplotlib等),MeteoInfo通过调用JMathLaTeX库也可以实现这样的功能。LaTeX的语法介绍可以参考此网页:http://matplotlib.org/users/mathtext.html

下面是两个例子:

 

脚本程序:

def  f(x, c):
    m1 = sin(2*pi*x)
    m2 = exp(-c*x)
    return m1 * m2
    
x = linspace(0, 4, 100)
sigma = 0.5
plot(x, f(x, sigma), 'r', linewidth=2)
xlabel(r'$\rm{time}  \  t$', fontsize=16)
ylabel(r'$\rm{Amplitude} \ f(x)$', fontsize=16)
title(r'$f(x) \ \rm{is \ damping  \ with} \ x$', fontsize=16)
text(2.0, 0.5, r'$f(x) = \rm{sin}(2 \pi  x^2) e^{\sigma x}$', fontsize=20)
show()
x = arange(0.01, 1, 0.01)
y = 0.5*log((1-x)/x)
scatter(x,y,s=4,label=r'$\alpha =\frac{1}{2}\ln(\frac{1-\varepsilon}{\varepsilon })$')
xlabel(r'$\varepsilon$',fontsize=20)
ylabel(r'$\alpha$',fontsize=20)
xlim(0,1)    
legend()
show()

 

posted on 2015-06-18 17:20  yaqiang  阅读(735)  评论(0编辑  收藏  举报

导航