Created
September 29, 2019 10:22
-
-
Save dradecic/f6c28a9cb3f0f04b74c2bccf35b811a5 to your computer and use it in GitHub Desktop.
recommender1_3_histogram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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