-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimgur_plot3.py
More file actions
34 lines (26 loc) · 1021 Bytes
/
imgur_plot3.py
File metadata and controls
34 lines (26 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import matplotlib.pyplot as plt
import pandas as pd
import six
#read the file
allimages = pd.read_csv('imgur_imagetags.csv', encoding = 'ISO-8859–1')
#filter the input to keep only images with more than 155000 views
images = allimages[allimages['views'] > 155000]
#keep a subset of columns and sort by upload_date
images = images[['image_id', 'upload_date', 'image_or_album', 'views', 'points', 'comment_count', 'tag_count']]
images = images.sort_values(by = ['upload_date'], ascending = [True])
#print(images)
#set up the table as a subplot
fig, ax = plt.subplots()
fig.patch.set_visible(False)
ax.axis('off')
ax.axis('tight')
the_table = ax.table(cellText = images.values, colLabels = images.columns, loc = 'center', cellLoc='center')
the_table.auto_set_font_size(False)
the_table.set_fontsize(10)
#format the header row
for k, cell in six.iteritems(the_table._cells):
if k[0] == 0:
cell.set_text_props(weight='bold', color='w')
cell.set_facecolor('#40466e')
#display the table
plt.show()