import pandas as pd
import matplotlib.pyplot as plt
Subplots
= pd.read_csv("data/salary.csv") data
data.head()
Age | All_Devs | Python | JavaScript | |
---|---|---|---|---|
0 | 18 | 17784 | 20046 | 16446 |
1 | 19 | 16500 | 17100 | 16791 |
2 | 20 | 18012 | 20000 | 18942 |
3 | 21 | 20628 | 24744 | 21780 |
4 | 22 | 25206 | 30500 | 25704 |
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"] js_salaries
= "Python")
plt.plot(ages, py_salaries, label = "JavaScript")
plt.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
plt.plot(ages, dev_salaries, label "Median Salaries in [USD] by Age")
plt.title("Age")
plt.xlabel("Salaries in USD")
plt.ylabel(
plt.legend() plt.tight_layout()
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"]
js_salaries
= plt.subplots()
fig, ax
= "Python")
plt.plot(ages, py_salaries, label = "JavaScript")
plt.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
plt.plot(ages, dev_salaries, label "Median Salaries in [USD] by Age")
plt.title("Age")
plt.xlabel("Salaries in USD")
plt.ylabel(
plt.legend() plt.tight_layout()
# 적용 객체를 변경
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"]
js_salaries
= plt.subplots()
fig, ax
= "Python")
ax.plot(ages, py_salaries, label = "JavaScript")
ax.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
ax.plot(ages, dev_salaries, label "Median Salaries in [USD] by Age")
ax.set_title("Age")
ax.set_xlabel("Salaries in USD")
ax.set_ylabel(
ax.legend() plt.tight_layout()
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"]
js_salaries
= plt.subplots(nrows = 2, ncols=1)
fig, (ax1, ax2)
= "Python")
ax2.plot(ages, py_salaries, label = "JavaScript")
ax2.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
ax1.plot(ages, dev_salaries, label
"Median Salaries in [USD] by Age")
ax1.set_title("Age")
ax1.set_xlabel("Salaries in USD")
ax1.set_ylabel(
ax1.legend()
"Median Salaries in [USD] by Age")
ax2.set_title("Age")
ax2.set_xlabel("Salaries in USD")
ax2.set_ylabel(
ax2.legend()
plt.tight_layout()
# 제목 및 xlabel 공유
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"]
js_salaries
= plt.subplots(nrows = 2, ncols=1)
fig, (ax1, ax2)
= "Python")
ax2.plot(ages, py_salaries, label = "JavaScript")
ax2.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
ax1.plot(ages, dev_salaries, label
"Median Salaries in [USD] by Age")
ax1.set_title("Salaries in USD")
ax1.set_ylabel(
ax1.legend()
"Age")
ax2.set_xlabel("Salaries in USD")
ax2.set_ylabel(
ax2.legend()
plt.tight_layout()
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"]
js_salaries
= plt.subplots(nrows = 2, ncols=1, sharex = True)
fig, (ax1, ax2)
= "Python")
ax2.plot(ages, py_salaries, label = "JavaScript")
ax2.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
ax1.plot(ages, dev_salaries, label
"Median Salaries in [USD] by Age")
ax1.set_title("Salaries in USD")
ax1.set_ylabel(
ax1.legend()
"Age")
ax2.set_xlabel("Salaries in USD")
ax2.set_ylabel(
ax2.legend()
plt.tight_layout()
= data["Age"]
ages = data["All_Devs"]
dev_salaries = data["Python"]
py_salaries = data["JavaScript"]
js_salaries
= plt.subplots()
fig1, ax1 = plt.subplots()
fig2, ax2
= "Python")
ax2.plot(ages, py_salaries, label = "JavaScript")
ax2.plot(ages, js_salaries, label = "All_Devs", linestyle = '--', color = "black")
ax1.plot(ages, dev_salaries, label
"Median Salaries in [USD] by Age")
ax1.set_title("Age")
ax1.set_xlabel("Salaries in USD")
ax1.set_ylabel(
ax1.legend()
"Median Salaries in [USD] by Age")
ax2.set_title("Age")
ax2.set_xlabel("Salaries in USD")
ax2.set_ylabel(
ax2.legend()
plt.tight_layout()