有人可以給我一個如何使用以下tickFormatters的例子。 docs對我沒有任何意義。Matplotlib Ticker
ticker.StrMethodFormatter() ticker.IndexFormatter()
例如我可能會認爲
x = np.array([ 316566.962, 294789.545, 490032.382, 681004.044, 753757.024,
385283.153, 651498.538, 937628.225, 199561.358, 601465.455])
y = np.array([ 208.075, 262.099, 550.066, 633.525, 612.804, 884.785,
862.219, 349.805, 279.964, 500.612])
money_formatter = tkr.StrMethodFormatter('${:,}')
plt.scatter(x,y)
ax = plt.gca()
fmtr = ticker.StrMethodFormatter('${:,}')
ax.xaxis.set_major_formatter(fmtr)
會爲我設置刻度標記是美元符號和逗號SEP爲成千上萬的地方ALA
['$300,000', '$400,000', '$500,000', '$600,000', '$700,000', '$800,000', '$900,000']
而是我得到一個索引錯誤。
IndexError: tuple index out of range
對於IndexFormatter
文檔說:
從標籤列表設置字符串
真的不知道這是什麼意思,當我嘗試使用它在我的抽動消失。
試着提供一個完整的例子,說明你有什麼,它產生了什麼,並解釋你想要生產什麼。 – Gabriel