-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_website_stats.py
71 lines (59 loc) · 2.17 KB
/
plot_website_stats.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Plot the evolution of website access as obtained from google analytics
"""
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
###############################################################################
stats = pd.read_csv(
'Analytics scikit-learn.sourceforge.net Audience Overview 20110101-20220430.csv',
skiprows=[0, 1, 2, 3, 4],
thousands=',')
# Drop last row which is an aggregate
stats = stats[:-1]
year = np.arange(len(stats['Month Index']))
year = year / 12. + 2011
###############################################################################
# Plot in white bg
plt.figure(figsize=(3.5, 2))
plt.plot(year, stats['Users'], linewidth=2, color='C1')
plt.ylim(0, )
plt.xticks([2010, 2012, 2014, 2016, 2018, 2020, 2022], size=12)
plt.xlim(xmax=year.max())
plt.yticks([2e5, 4e5, 6e5, 8e5, 1e6],
["200k", "400k", "600k", "800k", "1M"])
ax = plt.gca()
ax.yaxis.tick_right()
plt.grid(axis='y', color='.5')
ax.spines['left'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.tight_layout(pad=.1)
plt.savefig('sklearn_website_stats.pdf', facecolor='none',
edgecolor='none')
plt.savefig('sklearn_website_stats.svg', facecolor='none',
edgecolor='none')
plt.savefig('sklearn_website_stats.png', facecolor='none',
edgecolor='none', dpi=200)
###############################################################################
# Plot in white bg
import black_fig
black_fig.black_fig()
plt.figure(figsize=(3.5, 2))
plt.plot(year, stats['Users'], linewidth=2, color='C1')
plt.ylim(0, )
plt.xticks([2010, 2012, 2014, 2016, 2018, 2020, 2022], size=12)
plt.xlim(xmax=year.max())
plt.yticks([2e5, 4e5, 6e5, 8e5, 1e6],
["200k", "400k", "600k", "800k", "1M"])
ax = plt.gca()
ax.yaxis.tick_right()
plt.grid(axis='y', color='.2')
ax.spines['left'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.tight_layout(pad=.1)
plt.savefig('sklearn_website_stats_black.pdf', facecolor='none',
edgecolor='none')
plt.savefig('sklearn_website_stats_black.svg', facecolor='none',
edgecolor='none')
plt.savefig('sklearn_website_stats_black.png', facecolor='none',
edgecolor='none', dpi=200)