Matplotlib & Seaborn: Vẽ biểu đồ, trực quan hóa dữ liệu
Matplotlib & Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Tạo DataFrame mẫu
df = pd.DataFrame({
'age': [22, 25, 30, 35, 40],
'salary': [3000, 3500, 4000, 5000, 6000]
})
# Vẽ biểu đồ đường bằng Matplotlib
plt.plot(df['age'], df['salary'])
plt.xlabel('Tuổi')
plt.ylabel('Lương')
plt.title('Mối quan hệ Tuổi - Lương')
plt.show()
# Vẽ biểu đồ phân tán bằng Seaborn
sns.scatterplot(x='age', y='salary', data=df)
plt.show()PreviousPandas: Xử lý và phân tích dữ liệu dưới dạng bảngNextScikit-learn: Dùng để tiền xử lý dữ liệu (chuẩn hóa, mã hóa, chia tách dữ liệu
Last updated
