Matplotlib Series Code

This commit is contained in:
Corey Schafer
2019-06-08 21:11:19 -06:00
parent 2d2e572a78
commit bf5a05f6e7
33 changed files with 167689 additions and 0 deletions
@@ -0,0 +1,31 @@
from matplotlib import pyplot as plt
plt.xkcd()
ages_x = [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]
py_dev_y = [20046, 17100, 20000, 24744, 30500, 37732, 41247, 45372, 48876, 53850, 57287, 63016, 65998, 70003, 70000, 71496, 75370, 83640, 84666,
84392, 78254, 85000, 87038, 91991, 100000, 94796, 97962, 93302, 99240, 102736, 112285, 100771, 104708, 108423, 101407, 112542, 122870, 120000]
plt.plot(ages_x, py_dev_y, label='Python')
js_dev_y = [16446, 16791, 18942, 21780, 25704, 29000, 34372, 37810, 43515, 46823, 49293, 53437, 56373, 62375, 66674, 68745, 68746, 74583, 79000,
78508, 79996, 80403, 83820, 88833, 91660, 87892, 96243, 90000, 99313, 91660, 102264, 100000, 100000, 91660, 99240, 108000, 105000, 104000]
plt.plot(ages_x, js_dev_y, label='JavaScript')
dev_y = [17784, 16500, 18012, 20628, 25206, 30252, 34368, 38496, 42000, 46752, 49320, 53200, 56000, 62316, 64928, 67317, 68748, 73752, 77232,
78000, 78508, 79536, 82488, 88935, 90000, 90056, 95000, 90000, 91633, 91660, 98150, 98964, 100000, 98988, 100000, 108923, 105000, 103117]
plt.plot(ages_x, dev_y, color='#444444', linestyle='--', label='All Devs')
plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.title('Median Salary (USD) by Age')
plt.legend()
plt.tight_layout()
plt.savefig('plot.png')
plt.show()
Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

@@ -0,0 +1,31 @@
# Median Developer Salaries by Age
dev_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
dev_y = [38496, 42000, 46752, 49320, 53200,
56000, 62316, 64928, 67317, 68748, 73752]
# Median Python Developer Salaries by Age
py_dev_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
py_dev_y = [45372, 48876, 53850, 57287, 63016,
65998, 70003, 70000, 71496, 75370, 83640]
# Median JavaScript Developer Salaries by Age
js_dev_y = [37810, 43515, 46823, 49293, 53437,
56373, 62375, 66674, 68745, 68746, 74583]
# Ages 18 to 55
ages_x = [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]
py_dev_y = [20046, 17100, 20000, 24744, 30500, 37732, 41247, 45372, 48876, 53850, 57287, 63016, 65998, 70003, 70000, 71496, 75370, 83640, 84666,
84392, 78254, 85000, 87038, 91991, 100000, 94796, 97962, 93302, 99240, 102736, 112285, 100771, 104708, 108423, 101407, 112542, 122870, 120000]
js_dev_y = [16446, 16791, 18942, 21780, 25704, 29000, 34372, 37810, 43515, 46823, 49293, 53437, 56373, 62375, 66674, 68745, 68746, 74583, 79000,
78508, 79996, 80403, 83820, 88833, 91660, 87892, 96243, 90000, 99313, 91660, 102264, 100000, 100000, 91660, 99240, 108000, 105000, 104000]
dev_y = [17784, 16500, 18012, 20628, 25206, 30252, 34368, 38496, 42000, 46752, 49320, 53200, 56000, 62316, 64928, 67317, 68748, 73752, 77232,
78000, 78508, 79536, 82488, 88935, 90000, 90056, 95000, 90000, 91633, 91660, 98150, 98964, 100000, 98988, 100000, 108923, 105000, 103117]
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,36 @@
import csv
import numpy as np
import pandas as pd
from collections import Counter
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
data = pd.read_csv('data.csv')
ids = data['Responder_id']
lang_responses = data['LanguagesWorkedWith']
language_counter = Counter()
for response in lang_responses:
language_counter.update(response.split(';'))
languages = []
popularity = []
for item in language_counter.most_common(15):
languages.append(item[0])
popularity.append(item[1])
languages.reverse()
popularity.reverse()
plt.barh(languages, popularity)
plt.title("Most Popular Languages")
# plt.ylabel("Programming Languages")
plt.xlabel("Number of People Who Use")
plt.tight_layout()
plt.show()
@@ -0,0 +1,27 @@
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
ages_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
dev_y = [38496, 42000, 46752, 49320, 53200,
56000, 62316, 64928, 67317, 68748, 73752]
plt.plot(ages_x, dev_y, color="#444444", label="All Devs")
# py_dev_y = [45372, 48876, 53850, 57287, 63016,
# 65998, 70003, 70000, 71496, 75370, 83640]
# plt.plot(ages_x, py_dev_y, color="#008fd5", label="Python")
# js_dev_y = [37810, 43515, 46823, 49293, 53437,
# 56373, 62375, 66674, 68745, 68746, 74583]
# plt.plot(ages_x, js_dev_y, color="#e5ae38", label="JavaScript")
plt.legend()
plt.title("Median Salary (USD) by Age")
plt.xlabel("Ages")
plt.ylabel("Median Salary (USD)")
plt.tight_layout()
plt.show()
@@ -0,0 +1,15 @@
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
slices = [59219, 55466, 47544, 36443, 35917]
labels = ['JavaScript', 'HTML/CSS', 'SQL', 'Python', 'Java']
explode = [0, 0, 0, 0.1, 0]
plt.pie(slices, labels=labels, explode=explode, shadow=True,
startangle=90, autopct='%1.1f%%',
wedgeprops={'edgecolor': 'black'})
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()
@@ -0,0 +1,4 @@
# Language Popularity
slices = [59219, 55466, 47544, 36443, 35917, 31991, 27097, 23030, 20524, 18523, 18017, 7920, 7331, 7201, 5833]
labels = ['JavaScript', 'HTML/CSS', 'SQL', 'Python', 'Java', 'Bash/Shell/PowerShell', 'C#', 'PHP', 'C++', 'TypeScript', 'C', 'Other(s):', 'Ruby', 'Go', 'Assembly']
@@ -0,0 +1,14 @@
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()
# Colors:
# Blue = #008fd5
# Red = #fc4f30
# Yellow = #e5ae37
# Green = #6d904f
@@ -0,0 +1,27 @@
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
minutes = [1, 2, 3, 4, 5, 6, 7, 8, 9]
player1 = [8, 6, 5, 5, 4, 2, 1, 1, 0]
player2 = [0, 1, 2, 2, 2, 4, 4, 4, 4]
player3 = [0, 1, 1, 1, 2, 2, 3, 3, 4]
labels = ['player1', 'player2', 'player3']
colors = ['#6d904f', '#fc4f30', '#008fd5']
plt.stackplot(minutes, player1, player2, player3, labels=labels, colors=colors)
plt.legend(loc=(0.07, 0.05))
plt.title("My Awesome Stack Plot")
plt.tight_layout()
plt.show()
# Colors:
# Blue = #008fd5
# Red = #fc4f30
# Yellow = #e5ae37
# Green = #6d904f
@@ -0,0 +1,3 @@
player1 = [8, 6, 5, 5, 4, 2, 1, 1, 0]
player2 = [0, 1, 2, 2, 2, 4, 4, 4, 4]
player3 = [0, 1, 1, 1, 2, 2, 3, 3, 4]
@@ -0,0 +1,22 @@
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
minutes = [1, 2, 3, 4, 5, 6, 7, 8, 9]
player1 = [1, 2, 3, 3, 4, 4, 4, 4, 5]
player2 = [1, 1, 1, 1, 2, 2, 2, 3, 4]
player3 = [1, 1, 1, 2, 2, 2, 3, 3, 3]
plt.pie([1, 1, 1], labels=["Player 1", "Player2", "Player3"])
plt.title("My Awesome Stack Plot")
plt.tight_layout()
plt.show()
# Colors:
# Blue = #008fd5
# Red = #fc4f30
# Yellow = #e5ae37
# Green = #6d904f
@@ -0,0 +1,39 @@
Age,All_Devs,Python,JavaScript
18,17784,20046,16446
19,16500,17100,16791
20,18012,20000,18942
21,20628,24744,21780
22,25206,30500,25704
23,30252,37732,29000
24,34368,41247,34372
25,38496,45372,37810
26,42000,48876,43515
27,46752,53850,46823
28,49320,57287,49293
29,53200,45000,53437
30,56000,50000,56373
31,62316,55000,62375
32,64928,70000,66674
33,67317,71496,68745
34,68748,75370,68746
35,73752,83640,74583
36,77232,84666,79000
37,78000,84392,78508
38,78508,78254,79996
39,79536,85000,80403
40,82488,87038,83820
41,88935,91991,88833
42,90000,100000,91660
43,90056,94796,87892
44,95000,97962,96243
45,90000,93302,90000
46,91633,99240,99313
47,91660,102736,91660
48,98150,112285,102264
49,98964,100771,100000
50,100000,104708,100000
51,98988,108423,91660
52,100000,101407,99240
53,108923,112542,108000
54,105000,122870,105000
55,103117,120000,104000
1 Age All_Devs Python JavaScript
2 18 17784 20046 16446
3 19 16500 17100 16791
4 20 18012 20000 18942
5 21 20628 24744 21780
6 22 25206 30500 25704
7 23 30252 37732 29000
8 24 34368 41247 34372
9 25 38496 45372 37810
10 26 42000 48876 43515
11 27 46752 53850 46823
12 28 49320 57287 49293
13 29 53200 45000 53437
14 30 56000 50000 56373
15 31 62316 55000 62375
16 32 64928 70000 66674
17 33 67317 71496 68745
18 34 68748 75370 68746
19 35 73752 83640 74583
20 36 77232 84666 79000
21 37 78000 84392 78508
22 38 78508 78254 79996
23 39 79536 85000 80403
24 40 82488 87038 83820
25 41 88935 91991 88833
26 42 90000 100000 91660
27 43 90056 94796 87892
28 44 95000 97962 96243
29 45 90000 93302 90000
30 46 91633 99240 99313
31 47 91660 102736 91660
32 48 98150 112285 102264
33 49 98964 100771 100000
34 50 100000 104708 100000
35 51 98988 108423 91660
36 52 100000 101407 99240
37 53 108923 112542 108000
38 54 105000 122870 105000
39 55 103117 120000 104000
@@ -0,0 +1,33 @@
import pandas as pd
from matplotlib import pyplot as plt
data = pd.read_csv('data.csv')
ages = data['Age']
dev_salaries = data['All_Devs']
py_salaries = data['Python']
js_salaries = data['JavaScript']
plt.plot(ages, dev_salaries, color='#444444',
linestyle='--', label='All Devs')
plt.plot(ages, py_salaries, label='Python')
overall_median = 57287
plt.fill_between(ages, py_salaries, dev_salaries,
where=(py_salaries > dev_salaries),
interpolate=True, alpha=0.25, label='Above Avg')
plt.fill_between(ages, py_salaries, dev_salaries,
where=(py_salaries <= dev_salaries),
interpolate=True, color='red', alpha=0.25, label='Below Avg')
plt.legend()
plt.title('Median Salary (USD) by Age')
plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.tight_layout()
plt.show()
@@ -0,0 +1,25 @@
import pandas as pd
from matplotlib import pyplot as plt
data = pd.read_csv('data.csv')
ages = data['Age']
dev_salaries = data['All_Devs']
py_salaries = data['Python']
js_salaries = data['JavaScript']
plt.plot(ages, dev_salaries, color='#444444',
linestyle='--', label='All Devs')
plt.plot(ages, py_salaries, label='Python')
# overall_median = 57287
plt.legend()
plt.title('Median Salary (USD) by Age')
plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.tight_layout()
plt.show()
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,27 @@
import pandas as pd
from matplotlib import pyplot as plt
plt.style.use('fivethirtyeight')
data = pd.read_csv('data.csv')
ids = data['Responder_id']
ages = data['Age']
bins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
plt.hist(ages, bins=bins, edgecolor='black', log=True)
median_age = 29
color = '#fc4f30'
plt.axvline(median_age, color=color, label='Age Median', linewidth=2)
plt.legend()
plt.title('Ages of Respondents')
plt.xlabel('Ages')
plt.ylabel('Total Respondents')
plt.tight_layout()
plt.show()
@@ -0,0 +1,23 @@
import pandas as pd
from matplotlib import pyplot as plt
plt.style.use('fivethirtyeight')
ages = [18, 19, 21, 25, 26, 26, 30, 32, 38, 45, 55]
# data = pd.read_csv('data.csv')
# ids = data['Responder_id']
# ages = data['Age']
# median_age = 29
# color = '#fc4f30'
# plt.legend()
plt.title('Ages of Respondents')
plt.xlabel('Ages')
plt.ylabel('Total Respondents')
plt.tight_layout()
plt.show()
@@ -0,0 +1,201 @@
view_count,likes,ratio
8036001,324742,96.91
9378067,562589,98.19
2182066,273650,99.38
6525864,94698,96.25
9481284,582481,97.22
1853121,89903,97.46
2875684,183163,94.52
483827,4864,91.53
1677046,103227,97.52
289756,2387,92.95
2561907,237728,98.8
468390,25346,98.34
18977153,768968,98.73
365731,5997,93.29
680701,41543,97.99
5748289,225966,99.17
3575950,374937,97.69
865788,31806,98.3
5433739,389145,98.84
3643458,369667,97.88
247602,1516,89.18
300443,25429,99.49
313500,56891,98.35
3525217,92948,95.29
195072,23832,98.97
142697,20708,98.91
456783,2625,94.53
601565,38792,98.34
6021472,342044,97.54
940583,14292,97.7
446569,7557,97.15
767900,11091,97.14
5895810,98088,95.87
381910,45178,99.21
2468645,188315,98.73
407859,19407,98.77
846399,29308,95.93
872092,27298,94.85
1279718,98471,99.06
1068377,92634,98.89
4691951,164807,98.93
1091006,55346,98.53
891230,30612,88.39
720734,35647,98.11
1025214,19926,94.86
505146,3309,59.69
265430,2124,91.99
3651318,283911,98.64
1290212,201881,99.3
420393,5434,95.99
655107,21485,96.16
1010207,23720,95.85
777547,9167,94.46
686703,34001,98.54
1625877,62101,98.35
2107926,59334,97.3
1564214,81581,97.96
2277765,53425,89.82
1558609,95695,98.23
1689305,88050,95.43
3382856,74078,93.32
4835746,276098,94.3
248754,2041,90.75
687182,63309,97.61
751948,24359,98.3
737756,23093,82.35
964229,18898,86.34
973121,22810,97.6
575508,16975,94.75
1114419,35208,94.3
722956,21843,97.6
1560200,38185,96.52
281397,3706,91.53
1122525,28232,97.23
20650480,212862,91.88
225207,1524,84.76
598367,24260,94.51
2117363,162960,99.12
1233027,16400,88.81
2566897,112005,54.67
11907188,1234111,83.49
1477059,36018,98.75
292469,5656,92.71
466862,47754,98.96
1055798,46122,97.84
1278142,26021,97.37
1938747,16942,87.66
338563,8416,96.46
645274,17943,94.67
730110,26868,92.31
1521090,19761,86.6
1719425,79646,98.33
3028604,75484,97.22
1236239,55409,96.0
906642,14128,91.88
1257902,20899,92.93
1163635,30173,89.82
1413936,90918,97.87
709519,6013,95.14
628111,41450,97.03
2478832,143686,98.28
2524598,32486,93.66
821547,18708,97.31
3016943,38294,95.76
743575,20181,89.7
919626,22114,95.84
2536083,538376,99.6
959442,13220,95.94
2044159,41080,92.48
1554417,67165,93.0
2181022,180132,98.19
1010899,13696,97.57
2620663,72681,96.68
5732609,189529,97.16
1187273,73120,99.24
1594532,85661,97.01
8403016,294629,96.97
5972754,133474,96.6
6189511,267690,99.03
1042734,23761,91.61
9476773,417402,97.8
8040754,789213,98.73
2724624,88968,91.74
1085592,27288,98.51
3393417,219213,95.68
16396012,208578,79.21
3226905,19814,91.77
6276301,286642,98.15
647094,19753,89.98
8081040,477122,98.81
886934,29360,98.46
1228396,29893,98.2
697471,6452,94.85
1605670,78364,96.63
2056991,121925,98.44
397981,6185,58.36
2760289,106828,97.14
3655043,54069,89.65
10662064,320959,97.89
3105500,108620,96.6
2238691,48825,96.77
1153518,25832,96.44
686228,24882,96.57
7523411,614901,98.87
2641916,49354,95.78
11657853,233343,97.82
5932061,172195,95.91
6313988,323119,98.18
2850316,218273,98.14
2620142,36637,93.99
854120,54821,98.05
13799864,317613,96.07
906841,35315,98.09
689607,20658,98.58
441729,14901,99.0
797800,14327,95.41
1682016,75706,98.17
1426251,57965,98.73
2268534,91796,97.75
750032,39406,98.19
4272799,26229,98.03
2449662,80825,97.54
5988592,512483,99.4
3662227,75552,97.46
725964,42700,98.98
1647440,111190,98.85
985104,12721,96.5
1665692,23961,92.37
2051794,81790,96.64
4112883,116481,93.46
33297045,1293427,99.07
1517628,19931,96.25
1675692,18803,72.76
3626738,173591,98.44
1169663,7766,92.99
446959,4923,89.48
6995153,195994,96.69
519706,18975,98.94
4373224,169228,93.01
4024087,73080,97.71
731349,42205,98.52
94366013,4539630,97.66
2458132,34337,95.52
1812670,17476,94.43
2028445,158178,97.94
1335703,12622,94.14
938717,17120,97.26
2926955,42554,97.73
4018930,32919,82.1
6439402,81148,51.58
5665790,166892,96.95
899728,28115,96.49
2792057,206926,96.99
12839663,722491,97.84
5694139,146797,98.19
1069693,3970,90.66
590760,70454,99.18
319347,1208,92.5
27594927,1351963,96.4
26993425,437561,97.42
1 view_count likes ratio
2 8036001 324742 96.91
3 9378067 562589 98.19
4 2182066 273650 99.38
5 6525864 94698 96.25
6 9481284 582481 97.22
7 1853121 89903 97.46
8 2875684 183163 94.52
9 483827 4864 91.53
10 1677046 103227 97.52
11 289756 2387 92.95
12 2561907 237728 98.8
13 468390 25346 98.34
14 18977153 768968 98.73
15 365731 5997 93.29
16 680701 41543 97.99
17 5748289 225966 99.17
18 3575950 374937 97.69
19 865788 31806 98.3
20 5433739 389145 98.84
21 3643458 369667 97.88
22 247602 1516 89.18
23 300443 25429 99.49
24 313500 56891 98.35
25 3525217 92948 95.29
26 195072 23832 98.97
27 142697 20708 98.91
28 456783 2625 94.53
29 601565 38792 98.34
30 6021472 342044 97.54
31 940583 14292 97.7
32 446569 7557 97.15
33 767900 11091 97.14
34 5895810 98088 95.87
35 381910 45178 99.21
36 2468645 188315 98.73
37 407859 19407 98.77
38 846399 29308 95.93
39 872092 27298 94.85
40 1279718 98471 99.06
41 1068377 92634 98.89
42 4691951 164807 98.93
43 1091006 55346 98.53
44 891230 30612 88.39
45 720734 35647 98.11
46 1025214 19926 94.86
47 505146 3309 59.69
48 265430 2124 91.99
49 3651318 283911 98.64
50 1290212 201881 99.3
51 420393 5434 95.99
52 655107 21485 96.16
53 1010207 23720 95.85
54 777547 9167 94.46
55 686703 34001 98.54
56 1625877 62101 98.35
57 2107926 59334 97.3
58 1564214 81581 97.96
59 2277765 53425 89.82
60 1558609 95695 98.23
61 1689305 88050 95.43
62 3382856 74078 93.32
63 4835746 276098 94.3
64 248754 2041 90.75
65 687182 63309 97.61
66 751948 24359 98.3
67 737756 23093 82.35
68 964229 18898 86.34
69 973121 22810 97.6
70 575508 16975 94.75
71 1114419 35208 94.3
72 722956 21843 97.6
73 1560200 38185 96.52
74 281397 3706 91.53
75 1122525 28232 97.23
76 20650480 212862 91.88
77 225207 1524 84.76
78 598367 24260 94.51
79 2117363 162960 99.12
80 1233027 16400 88.81
81 2566897 112005 54.67
82 11907188 1234111 83.49
83 1477059 36018 98.75
84 292469 5656 92.71
85 466862 47754 98.96
86 1055798 46122 97.84
87 1278142 26021 97.37
88 1938747 16942 87.66
89 338563 8416 96.46
90 645274 17943 94.67
91 730110 26868 92.31
92 1521090 19761 86.6
93 1719425 79646 98.33
94 3028604 75484 97.22
95 1236239 55409 96.0
96 906642 14128 91.88
97 1257902 20899 92.93
98 1163635 30173 89.82
99 1413936 90918 97.87
100 709519 6013 95.14
101 628111 41450 97.03
102 2478832 143686 98.28
103 2524598 32486 93.66
104 821547 18708 97.31
105 3016943 38294 95.76
106 743575 20181 89.7
107 919626 22114 95.84
108 2536083 538376 99.6
109 959442 13220 95.94
110 2044159 41080 92.48
111 1554417 67165 93.0
112 2181022 180132 98.19
113 1010899 13696 97.57
114 2620663 72681 96.68
115 5732609 189529 97.16
116 1187273 73120 99.24
117 1594532 85661 97.01
118 8403016 294629 96.97
119 5972754 133474 96.6
120 6189511 267690 99.03
121 1042734 23761 91.61
122 9476773 417402 97.8
123 8040754 789213 98.73
124 2724624 88968 91.74
125 1085592 27288 98.51
126 3393417 219213 95.68
127 16396012 208578 79.21
128 3226905 19814 91.77
129 6276301 286642 98.15
130 647094 19753 89.98
131 8081040 477122 98.81
132 886934 29360 98.46
133 1228396 29893 98.2
134 697471 6452 94.85
135 1605670 78364 96.63
136 2056991 121925 98.44
137 397981 6185 58.36
138 2760289 106828 97.14
139 3655043 54069 89.65
140 10662064 320959 97.89
141 3105500 108620 96.6
142 2238691 48825 96.77
143 1153518 25832 96.44
144 686228 24882 96.57
145 7523411 614901 98.87
146 2641916 49354 95.78
147 11657853 233343 97.82
148 5932061 172195 95.91
149 6313988 323119 98.18
150 2850316 218273 98.14
151 2620142 36637 93.99
152 854120 54821 98.05
153 13799864 317613 96.07
154 906841 35315 98.09
155 689607 20658 98.58
156 441729 14901 99.0
157 797800 14327 95.41
158 1682016 75706 98.17
159 1426251 57965 98.73
160 2268534 91796 97.75
161 750032 39406 98.19
162 4272799 26229 98.03
163 2449662 80825 97.54
164 5988592 512483 99.4
165 3662227 75552 97.46
166 725964 42700 98.98
167 1647440 111190 98.85
168 985104 12721 96.5
169 1665692 23961 92.37
170 2051794 81790 96.64
171 4112883 116481 93.46
172 33297045 1293427 99.07
173 1517628 19931 96.25
174 1675692 18803 72.76
175 3626738 173591 98.44
176 1169663 7766 92.99
177 446959 4923 89.48
178 6995153 195994 96.69
179 519706 18975 98.94
180 4373224 169228 93.01
181 4024087 73080 97.71
182 731349 42205 98.52
183 94366013 4539630 97.66
184 2458132 34337 95.52
185 1812670 17476 94.43
186 2028445 158178 97.94
187 1335703 12622 94.14
188 938717 17120 97.26
189 2926955 42554 97.73
190 4018930 32919 82.1
191 6439402 81148 51.58
192 5665790 166892 96.95
193 899728 28115 96.49
194 2792057 206926 96.99
195 12839663 722491 97.84
196 5694139 146797 98.19
197 1069693 3970 90.66
198 590760 70454 99.18
199 319347 1208 92.5
200 27594927 1351963 96.4
201 26993425 437561 97.42
@@ -0,0 +1,27 @@
import pandas as pd
from matplotlib import pyplot as plt
plt.style.use('seaborn')
data = pd.read_csv('2019-05-31-data.csv')
view_count = data['view_count']
likes = data['likes']
ratio = data['ratio']
plt.scatter(view_count, likes, c=ratio, cmap='summer',
edgecolor='black', linewidth=1, alpha=0.75)
cbar = plt.colorbar()
cbar.set_label('Like/Dislike Ratio')
plt.xscale('log')
plt.yscale('log')
plt.title('Trending YouTube Videos')
plt.xlabel('View Count')
plt.ylabel('Total Likes')
plt.tight_layout()
plt.show()
@@ -0,0 +1,27 @@
import pandas as pd
from matplotlib import pyplot as plt
plt.style.use('seaborn')
x = [5, 7, 8, 5, 6, 7, 9, 2, 3, 4, 4, 4, 2, 6, 3, 6, 8, 6, 4, 1]
y = [7, 4, 3, 9, 1, 3, 2, 5, 2, 4, 8, 7, 1, 6, 4, 9, 7, 7, 5, 1]
# colors = [7, 5, 9, 7, 5, 7, 2, 5, 3, 7, 1, 2, 8, 1, 9, 2, 5, 6, 7, 5]
# sizes = [209, 486, 381, 255, 191, 315, 185, 228, 174,
# 538, 239, 394, 399, 153, 273, 293, 436, 501, 397, 539]
# data = pd.read_csv('2019-05-31-data.csv')
# view_count = data['view_count']
# likes = data['likes']
# ratio = data['ratio']
# plt.title('Trending YouTube Videos')
# plt.xlabel('View Count')
# plt.ylabel('Total Likes')
plt.tight_layout()
plt.show()
+15
View File
@@ -0,0 +1,15 @@
Date,Open,High,Low,Close,Adj Close,Volume
2019-05-18,7266.080078,8281.660156,7257.259766,8193.139648,8193.139648,723011166
2019-05-19,8193.139648,8193.139648,7591.850098,7998.290039,7998.290039,637617163
2019-05-20,7998.290039,8102.319824,7807.770020,7947.930176,7947.930176,357803946
2019-05-21,7947.930176,8033.759766,7533.660156,7626.890137,7626.890137,424501866
2019-05-22,7626.890137,7971.259766,7478.740234,7876.500000,7876.500000,386766321
2019-05-23,7876.500000,8165.450195,7801.569824,7996.399902,7996.399902,413162746
2019-05-24,7996.399902,8140.819824,7948.680176,8059.129883,8059.129883,179206342
2019-05-25,8059.129883,8779.000000,7894.529785,8726.230469,8726.230469,483663699
2019-05-26,8726.230469,8931.530273,8668.459961,8785.169922,8785.169922,507164714
2019-05-27,8785.169922,8818.709961,8562.200195,8718.849609,8718.849609,360752199
2019-05-28,8718.849609,8760.480469,8444.099609,8664.559570,8664.559570,380343928
2019-05-29,8664.559570,9065.889648,8027.209961,8276.250000,8276.250000,815525590
2019-05-30,8276.250000,8570.780273,8116.000000,8560.080078,8560.080078,500141087
2019-05-31,8550.629883,8576.339844,8459.650391,8504.980469,8504.980469,69915456
1 Date Open High Low Close Adj Close Volume
2 2019-05-18 7266.080078 8281.660156 7257.259766 8193.139648 8193.139648 723011166
3 2019-05-19 8193.139648 8193.139648 7591.850098 7998.290039 7998.290039 637617163
4 2019-05-20 7998.290039 8102.319824 7807.770020 7947.930176 7947.930176 357803946
5 2019-05-21 7947.930176 8033.759766 7533.660156 7626.890137 7626.890137 424501866
6 2019-05-22 7626.890137 7971.259766 7478.740234 7876.500000 7876.500000 386766321
7 2019-05-23 7876.500000 8165.450195 7801.569824 7996.399902 7996.399902 413162746
8 2019-05-24 7996.399902 8140.819824 7948.680176 8059.129883 8059.129883 179206342
9 2019-05-25 8059.129883 8779.000000 7894.529785 8726.230469 8726.230469 483663699
10 2019-05-26 8726.230469 8931.530273 8668.459961 8785.169922 8785.169922 507164714
11 2019-05-27 8785.169922 8818.709961 8562.200195 8718.849609 8718.849609 360752199
12 2019-05-28 8718.849609 8760.480469 8444.099609 8664.559570 8664.559570 380343928
13 2019-05-29 8664.559570 9065.889648 8027.209961 8276.250000 8276.250000 815525590
14 2019-05-30 8276.250000 8570.780273 8116.000000 8560.080078 8560.080078 500141087
15 2019-05-31 8550.629883 8576.339844 8459.650391 8504.980469 8504.980469 69915456
@@ -0,0 +1,26 @@
import pandas as pd
from datetime import datetime, timedelta
from matplotlib import pyplot as plt
from matplotlib import dates as mpl_dates
plt.style.use('seaborn')
data = pd.read_csv('data.csv')
data['Date'] = pd.to_datetime(data['Date'])
data.sort_values('Date', inplace=True)
price_date = data['Date']
price_close = data['Close']
plt.plot_date(price_date, price_close, linestyle='solid')
plt.gcf().autofmt_xdate()
plt.title('Bitcoin Prices')
plt.xlabel('Date')
plt.ylabel('Closing Price')
plt.tight_layout()
plt.show()
@@ -0,0 +1,30 @@
import pandas as pd
from datetime import datetime, timedelta
from matplotlib import pyplot as plt
from matplotlib import dates as mpl_dates
plt.style.use('seaborn')
dates = [
datetime(2019, 5, 24),
datetime(2019, 5, 25),
datetime(2019, 5, 26),
datetime(2019, 5, 27),
datetime(2019, 5, 28),
datetime(2019, 5, 29),
datetime(2019, 5, 30)
]
y = [0, 1, 3, 4, 6, 5, 7]
# data = pd.read_csv('data.csv')
# price_date = data['Date']
# price_close = data['Close']
# plt.title('Bitcoin Prices')
# plt.xlabel('Date')
# plt.ylabel('Closing Price')
plt.tight_layout()
plt.show()
+35
View File
@@ -0,0 +1,35 @@
import csv
import random
import time
x_value = 0
total_1 = 1000
total_2 = 1000
fieldnames = ["x_value", "total_1", "total_2"]
with open('data.csv', 'w') as csv_file:
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
csv_writer.writeheader()
while True:
with open('data.csv', 'a') as csv_file:
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
info = {
"x_value": x_value,
"total_1": total_1,
"total_2": total_2
}
csv_writer.writerow(info)
print(x_value, total_1, total_2)
x_value += 1
total_1 = total_1 + random.randint(-6, 8)
total_2 = total_2 + random.randint(-5, 6)
time.sleep(1)
@@ -0,0 +1,34 @@
import random
from itertools import count
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
plt.style.use('fivethirtyeight')
x_vals = []
y_vals = []
index = count()
def animate(i):
data = pd.read_csv('data.csv')
x = data['x_value']
y1 = data['total_1']
y2 = data['total_2']
plt.cla()
plt.plot(x, y1, label='Channel 1')
plt.plot(x, y2, label='Channel 2')
plt.legend(loc='upper left')
plt.tight_layout()
ani = FuncAnimation(plt.gcf(), animate, interval=1000)
plt.tight_layout()
plt.show()
@@ -0,0 +1,26 @@
# Another way to do it without clearing the Axis
def animate(i):
data = pd.read_csv('data.csv')
x = data['x_value']
y1 = data['total_1']
y2 = data['total_2']
line1.set_data(x, y1)
line2.set_data(x, y2)
ax = plt.gca()
xlim_low, xlim_high = ax.get_xlim()
ylim_low, ylim_high = ax.get_ylim()
ax.set_xlim(xlim_low, (x.max() + 5))
y1max = y1.max()
y2max = y2.max()
current_ymax = y1max if (y1max > y2max) else y2max
y1min = y1.min()
y2min = y2.min()
current_ymin = y1min if (y1min < y2min) else y2min
ax.set_ylim((current_ymin - 5), (current_ymax + 5))
@@ -0,0 +1,29 @@
import random
from itertools import count
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
x_vals = [0, 1, 2, 3, 4, 5]
y_vals = [0, 1, 3, 2, 3, 5]
plt.plot(x_vals, y_vals)
# index = count()
# def animate(i):
# x_vals.append(next(index))
# y_vals.append(random.randint(0, 5))
plt.tight_layout()
plt.show()
# data = pd.read_csv('data.csv')
# x = data['x_value']
# y1 = data['total_1']
# y2 = data['total_2']
+39
View File
@@ -0,0 +1,39 @@
Age,All_Devs,Python,JavaScript
18,17784,20046,16446
19,16500,17100,16791
20,18012,20000,18942
21,20628,24744,21780
22,25206,30500,25704
23,30252,37732,29000
24,34368,41247,34372
25,38496,45372,37810
26,42000,48876,43515
27,46752,53850,46823
28,49320,57287,49293
29,53200,63016,53437
30,56000,65998,56373
31,62316,70003,62375
32,64928,70000,66674
33,67317,71496,68745
34,68748,75370,68746
35,73752,83640,74583
36,77232,84666,79000
37,78000,84392,78508
38,78508,78254,79996
39,79536,85000,80403
40,82488,87038,83820
41,88935,91991,88833
42,90000,100000,91660
43,90056,94796,87892
44,95000,97962,96243
45,90000,93302,90000
46,91633,99240,99313
47,91660,102736,91660
48,98150,112285,102264
49,98964,100771,100000
50,100000,104708,100000
51,98988,108423,91660
52,100000,101407,99240
53,108923,112542,108000
54,105000,122870,105000
55,103117,120000,104000
1 Age All_Devs Python JavaScript
2 18 17784 20046 16446
3 19 16500 17100 16791
4 20 18012 20000 18942
5 21 20628 24744 21780
6 22 25206 30500 25704
7 23 30252 37732 29000
8 24 34368 41247 34372
9 25 38496 45372 37810
10 26 42000 48876 43515
11 27 46752 53850 46823
12 28 49320 57287 49293
13 29 53200 63016 53437
14 30 56000 65998 56373
15 31 62316 70003 62375
16 32 64928 70000 66674
17 33 67317 71496 68745
18 34 68748 75370 68746
19 35 73752 83640 74583
20 36 77232 84666 79000
21 37 78000 84392 78508
22 38 78508 78254 79996
23 39 79536 85000 80403
24 40 82488 87038 83820
25 41 88935 91991 88833
26 42 90000 100000 91660
27 43 90056 94796 87892
28 44 95000 97962 96243
29 45 90000 93302 90000
30 46 91633 99240 99313
31 47 91660 102736 91660
32 48 98150 112285 102264
33 49 98964 100771 100000
34 50 100000 104708 100000
35 51 98988 108423 91660
36 52 100000 101407 99240
37 53 108923 112542 108000
38 54 105000 122870 105000
39 55 103117 120000 104000
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

@@ -0,0 +1,35 @@
import pandas as pd
from matplotlib import pyplot as plt
plt.style.use('seaborn')
data = pd.read_csv('data.csv')
ages = data['Age']
dev_salaries = data['All_Devs']
py_salaries = data['Python']
js_salaries = data['JavaScript']
fig1, ax1 = plt.subplots()
fig2, ax2 = plt.subplots()
ax1.plot(ages, dev_salaries, color='#444444',
linestyle='--', label='All Devs')
ax2.plot(ages, py_salaries, label='Python')
ax2.plot(ages, js_salaries, label='JavaScript')
ax1.legend()
ax1.set_title('Median Salary (USD) by Age')
ax1.set_ylabel('Median Salary (USD)')
ax2.legend()
ax2.set_xlabel('Ages')
ax2.set_ylabel('Median Salary (USD)')
plt.tight_layout()
plt.show()
fig1.savefig('fig1.png')
fig2.savefig('fig2.png')
@@ -0,0 +1,27 @@
import pandas as pd
from matplotlib import pyplot as plt
plt.style.use('seaborn')
data = pd.read_csv('data.csv')
ages = data['Age']
dev_salaries = data['All_Devs']
py_salaries = data['Python']
js_salaries = data['JavaScript']
plt.plot(ages, py_salaries, label='Python')
plt.plot(ages, js_salaries, label='JavaScript')
plt.plot(ages, dev_salaries, color='#444444',
linestyle='--', label='All Devs')
plt.legend()
plt.title('Median Salary (USD) by Age')
plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.tight_layout()
plt.show()