
如果要做到这一点你可以使用一般的情况下
FuncFormatter(参见:
matplotlib轴标签格式,[mshow:标签作为图像索引的任意功能。Matplotlib
set_major_formatterAttributeError的
在您这种情况下,以下方法应该起作用:
import matplotlib as mplimport matplotlib.pyplot as pltdef mjrFormatter(x, pos): return "^{{{0}}}$".format(x)def mjrFormatter_no_TeX(x, pos): return "2^{0}".format(x)ax = plt.gca()ax.yaxis.set_major_formatter(mpl.ticker.FuncFormatter(mjrFormatter))plt.draw()该absured
{}转义是新型串frommating的结果欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)