我今天试着在图形中渲染一些纹理,但没用。我意识到,matplotlibrc文件中的text.usetex
被设置为False
。
当我将rc('text', usetex=True)
添加到脚本中时,轴标签也呈现为TeX,这是不需要的。
我不记得在matplotlib 1.3.0之前设置过这个,而且我绝对不记得渲染TeX有什么困难
还有人经历过这种行为吗?在
示例:
import matplotlib.patheffects as PathEffects
# matplotlib.rc('text', usetex=True)
fig = plt.figure(figsize=(4,4))
ax = fig.add_axes([0,0,0.9,1])
ax.imshow(randn(20,20))
txt = ax.text(0.1, 0.5, r"Some \LaTeX\ $\alpha=\beta$", transform=ax.transAxes,fontsize=16)
txt.set_path_effects([PathEffects.Stroke(linewidth=3, foreground="w"), PathEffects.Normal()])
产生:
取消注释`matplotlib.rc文件('text',usetex=True)'行,生成:
你的“问题”其实不是一个问题,但我假设你有以下问题:
您希望使用latex字体向绘图中添加一些文本,或者只添加数学而不使用
rc('text', usetex=True)
(请注意,在默认的rcparams文件中,它声明这会影响all文本)。在可以这样做:
希望能有所帮助!在
相关问题 更多 >
编程相关推荐