Skip to content

Instantly share code, notes, and snippets.

@Ffisegydd
Forked from joncle/gist:cd69e402ee335c92ad4a
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Ffisegydd/f4de96caa689123c9644 to your computer and use it in GitHub Desktop.
Save Ffisegydd/f4de96caa689123c9644 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
calls = np.random.random_integers(100, 5000, 31)
days = np.arange(1, 32)
fig, ax = plt.subplots()
# Default width is already 0.8 but you can adjust it if you so wish
width = 0.8
# Need to align center to make sure the ticks are directly below the bars
bar = ax.bar(days, calls, color='#4f7094', width=width, align='center')
ax.set_xticks(days)
for rect in bar[1::2]:
rect.set_color('#1e3046')
# Removes the spines around the border.
for spine in ['top', 'left', 'bottom', 'right']:
ax.spines[spine].set_visible(False)
# Removes unwanted ticks and labels
tick_args = dict(which='both', left='off', labelleft='off', right='off',
top='off', bottom='off', labelbottom='on')
plt.tick_params(**tick_args)
ax.set_xlim(0,32)
plt.tight_layout() # Sorts out the overlapping objects
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment