添加上标:^
添加下标:_
举例:
import numpy as np
import matplotlib.pyplot as pltt = np.linspace(0, 10, 1000)
y = np.sin(t)
plt.plot(t, y)
plt.xlabel('a/${m_2}$',fontdict={'weight': 'normal', 'size': 15})
plt.show()
效果:
如果去掉斜体格式:
import numpy as np
import matplotlib.pyplot as pltt = np.linspace(0, 10, 1000)
y = np.sin(t)
plt.plot(t, y)
plt.xlabel('a/$\mathregular{m_2}$',fontdict={'weight': 'normal', 'size': 15})
plt.show()
效果:
添加上标:
import numpy as np
import matplotlib.pyplot as pltt = np.linspace(0, 10, 1000)
y = np.sin(t)
plt.plot(t, y)
plt.xlabel('a/$\mathregular{m^2}$',fontdict={'weight': 'normal', 'size': 15})
plt.show()