I want to apply decimal and thousands separator to cbar
in Seaborm plot in order to see numbers formatted like this: 4.294.967.295,00
. I know how to format xaxis
and yaxis
, but cannot apply this formating to cbar
.
plt.figure(figsize=(12,8))
ax = sns.heatmap(df, annot=False, linewidths=.5)
ax.get_yaxis().set_major_formatter(
matplotlib.ticker.FuncFormatter(lambda x,p: str(int(x))+":00"))
plt.show()
This template code should help you out. Takes an unformatted number, adds the "," before the last 2 digits, then goes through and adds the "." every 3 characters.
number = "1000000000"
temp = ""
temp += number[:-2] + "," + number[-2:]
e = list(temp.split(",")[0])
for i in range(len(e))[::-3][1:]:
e.insert(i+1,".")
result = "".join(e)+","+temp.split(",")[1]
print(result)
This is result for the static number I gave.: 10.000.000,00
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.