import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
speed = [4, 4, 7, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 20, 20, 20, 20, 20, 22, 23, 24, 24, 24, 24, 25]
dist = [2, 10, 4, 22, 16, 10, 18, 26, 34, 17, 28, 14, 20, 24, 28, 26, 34, 34, 46, 26, 36, 60, 80, 20, 26, 54, 32, 40, 32, 40, 50, 42, 56, 76, 84, 36, 46, 68, 32, 48, 52, 56, 64, 66, 54, 70, 92, 93, 120, 85]
cars_df = pd.DataFrame(
{"speed": speed,
"dist": dist
}
)
# 散佈圖 (Scatter plot)
sns.jointplot(x = "speed", y = "dist", data = cars_df)
# 線圖(Line plot)
sns.factorplot(data = cars_df, x="speed", y="dist", ci = None)
# 長條圖(Bar plot)
sns.countplot(x = "speed", data = cars_df)
normal_samples = np.random.normal(size = 100000) # 生成 100000 組標準常態分配(平均值為 0,標準差為 1 的常態分配)隨機變數
# 直方圖 Histogram
sns.distplot(normal_samples)
# 盒鬚圖 Box plot
sns.boxplot(normal_samples)
import seaborn as sns
ax = sns.scatterplot(x="x1", y="x2", hue="NY", data=df)
ax = sns.boxplot(x="NY", y="x1", data=df)
沒有留言:
張貼留言