Skip to content

Instantly share code, notes, and snippets.

@mkhorasani
Last active October 10, 2021 15:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkhorasani/bfad2a83ed5c4de1b2e8348a8b07ec33 to your computer and use it in GitHub Desktop.
Save mkhorasani/bfad2a83ed5c4de1b2e8348a8b07ec33 to your computer and use it in GitHub Desktop.
def bar_chart(credit, debit, balance):
x = [x[0:6] for (x,y) in balance]
y1 = [y for (x,y) in credit]
y2 = [y for (x,y) in debit]
y3 = [y for (x,y) in balance]
n = len(x)
index = np.arange(n)
fig, ax = plt.subplots(1, 1, figsize=(16,7), dpi= 96)
plt.plot(x,y3,label='Balance',color='black',linewidth=2.0)
b1=plt.bar(index-0.0625,y1,label='Credit',color=[(0.06667,0.5647,0.7961)],width=0.125)
b2=plt.bar(index+0.0625,y2,label='Debit',color=[(1,0.4118,0.4118)],width=0.125)
plt.xticks(fontsize=14, rotation = 45, horizontalalignment='center',color='darkgrey')
plt.yticks(fontsize=14,color='darkgrey')
plt.xlim(-1.0)
ax.yaxis.grid(alpha=0.5)
plt.yscale('log', basey=1.00001)
for axis in [ax.yaxis]:
axis.set_major_formatter(ScalarFormatter())
plt.gca().spines["top"].set_alpha(0)
plt.gca().spines["bottom"].set_alpha(0.5)
plt.gca().spines["right"].set_alpha(0)
plt.gca().spines["left"].set_alpha(0)
plt.savefig('fig1.png',orientation='portrait',transparent=True, bbox_inches=None, pad_inches=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment