0

Looking to clean up some bar labels on the attached image. The code for the chart is also attached. I want to be able to have accounting format for the labels(thousands separator and 2 decimal places) (Ex. 1,000,000.00). I also would love if the labels were a little cleaner to read. Maybe rotated, moved, etc. I am extremely new to Python so any changes you suggest may have to be accompanied with some code.

Also, what would be the easiest way to attach the chart to an e-mail body?

Thanks everyone in advance! Image of Chart HERE

plt.style.use('seaborn-darkgrid')
fig, ax = plt.subplots()
sqldata.plot(x='AccountName',y=['t0','t30'],kind='bar', ax=ax)
ax.set_title(f"Financials Team Cash Sheet {todaydate}")
ax.set_ylabel('Cash')
ax.set_xlabel('Account')
ax.set_title(f"Financials Team Cash Sheet {todaydate}")
x = np.arange(len(sqldata))
y = np.arange(100000)
width = 0.35
ax.set_ylim(0,30000000)
ax.legend()
plt.ticklabel_format(style='plain', axis='y')
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('${x:,.0f}'))

#
rects1 = ax.bar(x - width/2, sqldata.t0, width, label='T+0')
rects2 = ax.bar(x + width/2, sqldata.t30, width, label='T+30')
ax.bar_label(rects1, padding=3, fmt='%d',label_type='center')
ax.bar_label(rects2, padding=3, fmt='%d')

plt.tight_layout()
plt.show()

Maestro
  • 1
  • 1
  • 1
    You may want to consider a horizontal bar graph. – r-beginners Sep 20 '21 at 14:23
  • This [answer](https://stackoverflow.com/a/67561982/7758804) from the duplicate: `ax.bar_label(rects2, padding=3, fmt='%d', rotation=90)` – Trenton McKinney Sep 20 '21 at 16:35
  • _what would be the easiest way to attach the chart to an e-mail body?_ is a separate question. So questions should be one, not multiple questions. Save it as a file and attach it. There are probably existing questions about how to add a file to an email, but you need to be specific about the exact requirements. – Trenton McKinney Sep 20 '21 at 16:36

0 Answers0