我试图根据参数(alpha)绘制函数的多次迭代,并且我想将参数的值传递给标签,以便标签看起来像alpha = 0.5。这样做就可以了,但是我希望用真实的Alpha(即LateX符号)来呈现Alpha参数。我怎样才能做到这一点?这是代码:#***************#* Phase angle * #***************def phase_angle(alpha,f_act,f_res): phi = numpy.arctan2(2*alpha*(f_act/f_res),(1-(f_act/f_res)**2)) return phi#**************************#* Setting the Parameters *#**************************f_min = 1f_max = 200f_eig = 75df=.1alpha =[0.01,0.05,0.5,1]#******************#* Initialization *#******************f = numpy.arange(f_min,f_max,df)Freq = f/f_eig#************************************#* Plotting the curve for the phase *#************************************# Publishable quality imageps.set_mode("beamer")# Plotting the curve for the kinematicsfig = pylab.figure()host = fig.add_subplot(111)host.set_title('Typical phase response of a resonant system')for alpha_i in alpha: Phase = phase_angle(alpha_i,f,f_eig) host.plot(Freq, Phase, label='\alpha=' + str(alpha_i), linewidth=2)host.axvline(x=1, linewidth=1.5, color='b')host.set_xlabel(r"Adimensioned frequency $f$/$f_{wing}$ [$-$]")host.set_ylabel(r"Phase response $\phi$ [$rad$]")Phase_pi = Phase/numpy.piy_tick = numpy.arange(0,1.5,0.5)y_label = [r"$0$", r"$+\frac{\pi}{2}$", r"$+\pi$"]host.set_yticks(y_tick*numpy.pi)host.set_yticklabels(y_label, fontsize=20)host.set_xlim(0,2.5)host.set_ylim(top=numpy.pi)pylab.legend(loc=0)pylab.tight_layout()pylab.show()我认为python在连接时会感到困惑。有什么想法吗?
1 回答

守候你守候我
TA贡献1802条经验 获得超10个赞
使用字符串格式(记住您的$)
for alpha_i in alpha:
Phase = phase_angle(alpha_i,f,f_eig)
host.plot(Freq, Phase, label=r'$\alpha = {0}$'.format(alpha_i), linewidth=2)
添加回答
举报
0/150
提交
取消