Skip to content

Instantly share code, notes, and snippets.

@dradecic
Created September 29, 2019 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dradecic/f6c28a9cb3f0f04b74c2bccf35b811a5 to your computer and use it in GitHub Desktop.
Save dradecic/f6c28a9cb3f0f04b74c2bccf35b811a5 to your computer and use it in GitHub Desktop.
recommender1_3_histogram
def make_histogram(dataset, attribute, bins=25, bar_color='#3498db', edge_color='#2980b9', title='Title', xlab='X', ylab='Y', sort_index=False):
if attribute == 'moviePubYear':
dataset = dataset[dataset['moviePubYear'] != 9999]
fig, ax = plt.subplots(figsize=(14, 7))
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.set_title(title, fontsize=24, pad=20)
ax.set_xlabel(xlab, fontsize=16, labelpad=20)
ax.set_ylabel(ylab, fontsize=16, labelpad=20)
plt.hist(dataset[attribute], bins=bins, color=bar_color, ec=edge_color, linewidth=2)
plt.xticks(rotation=45)
make_histogram(data, 'moviePubYear', title='Movies Published per Year', xlab='Year', ylab='Counts')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment