1
我想對齊matplotlib中的等號。因此,我使用matplotlib的eqnarray的環境:在matplotlib中使用latex「eqnarray」命令減少等號之間的間距?
import matplotlib.pyplot as plt
from matplotlib import rc
rc('text', usetex=True)
rc('font', size = 7)
fig = plt.figure(figsize=(3,2))
ax = fig.add_subplot(111)
ax.text(0.5,0.5 ,r'\begin{eqnarray*}' +\
r'M &=& 0.95' + '\\\\' +\
r'\xi &=& 0.5' + '\\\\' +\
r'\mu &=& 0.1' + '\\\\' +\
r'a/b &=& 0' + '\\\\' +\
r'\delta_{99}/L &=& 0' +\
r'\end{eqnarray*}',
verticalalignment='center',
horizontalalignment='center')
plt.savefig('output.pdf')
plt.show()
我怎樣才能減少間距的等號附近?
您可以與= 0.95' + '\\\\'''通過更換r'M的原始字符串'r'M &=&0.95 \\'',這是'r'上的好事;) – Luis
@Luis:在代碼中看起來更好,但輸出仍然相同。 – malohm
好吧,它使用'對齊',以下這種方法:https://stackoverflow.com/questions/30515888/align-latex-math-text-in-matplotlib-text-box – malohm