Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Python Pandas - Vẽ point plot và đặt mũi tên cho thanh lỗi với Seaborn


Point Plot trong Seaborn hiển thị ước lượng điểm và khoảng tin cậy bằng điểm phân tán. Dùng seaborn.pointplot(). Đặt mũi tên cho thanh lỗi bằng tham số capsize.

Dữ liệu: Cricketers.csv.

Nhập thư viện:

import seaborn as sb 
import pandas as pd 
import matplotlib.pyplot as plt

Tải dữ liệu:

dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers.csv")

Đặt mũi tên cho thanh lỗi:

sb.pointplot(dataFrame['Role'], dataFrame['Age'], capsize=.3)

Ví dụ

import seaborn as sb 
import pandas as pd 
import matplotlib.pyplot as plt 
# Tải dữ liệu 
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers.csv") 
sb.set_theme(style="darkgrid") 
# Point plot với mũi tên thanh lỗi 
sb.pointplot(dataFrame['Role'], dataFrame['Age'], capsize=.3) 
plt.show()

Kết quả

Python Pandas - Vẽ point plot và đặt mũi tên cho thanh lỗi với Seaborn