Am just starting to learn matplotlib and want to have 4 subplots (2x2) that have y axis labels formatted with dollar signs and commas.
I have looked at this post and this post and wrote the following code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
x = [i*100 for i in range(10)]
y = [i*1000 for i in range(10)]
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row')
plt.ylim(0,15000)
fmt = '${x:,.0f}'
tick = mtick.StrMethodFormatter(fmt)
ax.yaxis.set_major_formatter(tick)
ax1.scatter(x,y, color='r')
ax2.scatter(x,y, color='r')
ax3.scatter(x, y , color='r')
ax4.scatter(x, y, color='r')
ax1.set_title('Sharing x per column, y per row')
plt.show()
But the plots that I get have different y axis labels and neither of them have dollar signs or commas as seen here: 2 x 2 subplots without proper y labels