Skip to content

Commit f05b075

Browse files
committed
Subplots - matplotlib series
1 parent f8744d5 commit f05b075

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

10-Subplots/data.csv

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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

10-Subplots/demo.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import pandas as pd
2+
from matplotlib import pyplot as plt
3+
4+
plt.style.use('seaborn')
5+
6+
7+
data = pd.read_csv('data.csv')
8+
ages = data['Age']
9+
dev_salaries = data['All_Devs']
10+
py_salaries = data['Python']
11+
js_salaries = data['JavaScript']
12+
13+
fig1, ax1 = plt.subplots()
14+
fig2, ax2 = plt.subplots()
15+
16+
ax1.plot(ages, dev_salaries, color='#444444',
17+
linestyle='--', label='All Devs')
18+
19+
ax2.plot(ages, py_salaries, label='Python')
20+
ax2.plot(ages, js_salaries, label='JavaScript')
21+
22+
ax1.legend()
23+
ax1.set_title('Median Salary (USD) by Age')
24+
ax1.set_ylabel('Median Salary (USD)')
25+
26+
ax2.legend()
27+
ax2.set_xlabel('Ages')
28+
ax2.set_ylabel('Median Salary (USD)')
29+
30+
plt.tight_layout()
31+
32+
plt.show()
33+
34+
fig1.savefig('fig1.png')
35+
fig2.savefig('fig2.png')

10-Subplots/fig1.png

31.5 KB
Loading

10-Subplots/fig2.png

47.2 KB
Loading

0 commit comments

Comments
 (0)