matplotlib:更改yaxis刻度标签

matplotlib:更改yaxis刻度标签,第1张

matplotlib:更改yaxis刻度标签

如果要做到这一点你可以使用一般的情况下

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的结果



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5674401.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存