I want to change the format of the text created with matplotlib.pyplot.text
- That I'm adding the text above each bar in a bar plot. But I dont know how. I have tried the approach suggested in this question, was able to change the format on the y axis, but had no success with the text boxes.
This is the method used in the linked question (which I also used for my y axis):
fig, ax = plt.subplots(1, 1, figsize=(8, 5))
fmt = '${x:,.0f}'
tick = mtick.StrMethodFormatter(fmt)
ax.yaxis.set_major_formatter(tick)
And this is code that I'm using to create the text:
for i in range(len(cost_tbl)):
ax.text(i-0.2, cost_tbl[i, 2]+18000, str(int(cost_tbl[i, 2])), rotation=60)