如何在matplotlib中放大/缩小xlabel/ylabel中绘制的箭头?
在中,解释了xlabel/ylabel中箭头的生成。该说明提供了一个示例:如何在matplotlib中放大/缩小xlabel/ylabel中绘制的箭头?,matplotlib,subplot,Matplotlib,Subplot,在中,解释了xlabel/ylabel中箭头的生成。该说明提供了一个示例: import matplotlib.pyplot as plt fig, ax = plt.subplots(1, 1) # plot your data here ... ax.set_xlabel(r'$\rho/\rho_{ref}\;\rightarrow$', color='red') ax.set_ylabel(r'$\Delta \Theta / \omega \longrightarrow$') p
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
# plot your data here ...
ax.set_xlabel(r'$\rho/\rho_{ref}\;\rightarrow$', color='red')
ax.set_ylabel(r'$\Delta \Theta / \omega \longrightarrow$')
plt.show()
结果如下:
如果您使用
LaTeX
渲染文本(使用rcParams
),那么您可以使用LaTeX
大小命令更改部分文本。例如:
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
fig, ax = plt.subplots(1, 1)
ax.set_xlabel(r'$\rho/\rho_{ref} \;$ \Huge{$ \rightarrow $}', color='red')
ax.set_ylabel(r'$\Delta \Theta / \omega $ \Huge{$\longrightarrow$}')
plt.show()
我将借此机会发布广告,以适合我的顾问口味的方式格式化matplotlib图形。他还喜欢在轴标签上加箭头。我使用FancyArrow实现了它们。请看一下教程。