-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path07-legends.py
65 lines (39 loc) · 1.79 KB
/
07-legends.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
import matplotlib.pyplot as plt
year = [2014, 2015, 2016, 2017, 2018, 2019]
tutorial_public = [39, 117, 98, 54, 28, 15]
tutorial_premium = [0, 0, 13, 56, 39, 14]
def legends_fail():
plt.plot(year, tutorial_public, color="#6c3376", linewidth=3)
plt.plot(year, tutorial_premium, color="#f3e151", linewidth=3)
plt.xlabel('Year')
plt.ylabel('Number of futurestud.io Tutorials')
plt.legend()
plt.show()
def legends_simple():
plt.plot(year, tutorial_public, label='Public Tutorials', color="#6c3376", linewidth=3)
plt.plot(year, tutorial_premium, label='Premium Tutorials', color="#f3e151", linewidth=3)
plt.xlabel('Year')
plt.ylabel('Number of futurestud.io Tutorials')
plt.legend()
plt.show()
def legends_alternative():
public, = plt.plot(year, tutorial_public, color="#6c3376", linewidth=3)
premium, = plt.plot(year, tutorial_premium, color="#f3e151", linewidth=3)
plt.xlabel('Year')
plt.ylabel('Number of futurestud.io Tutorials')
plt.legend([public, premium], ['Public Tutorials', 'Premium Tutorials'])
plt.show()
def legends_custom():
plt.plot(year, tutorial_public, label='Public Tutorials', color="#6c3376", linewidth=3)
plt.plot(year, tutorial_premium, label='Premium Tutorials', color="#f3e151", linewidth=3)
plt.xlabel('Year')
plt.ylabel('Number of futurestud.io Tutorials')
plt.legend(loc='upper left', ncol=2)
plt.show()
def legends_custom2():
plt.plot(year, tutorial_public, label='Public Tutorials', color="#6c3376", linewidth=3)
plt.plot(year, tutorial_premium, label='Premium Tutorials', color="#f3e151", linewidth=3)
plt.xlabel('Year')
plt.ylabel('Number of futurestud.io Tutorials')
plt.legend(loc='upper right', title='Cool Legend', frameon=False, fontsize='large')
plt.show()