- relplot()
- 데이터를 가지고 요일별로 분리된 scatter plot을 볼 수 있으며 labeling을 해줄 수 있다.
import seaborn as sns
import matplotlib.pyplot as plt
sns.relplot(x="total_bill", y="tip", data=tips, kind="scatter"
, col="day", col_order=["Thur","Fri","Sat","Sun"])
plt.show()
- 연습 1
- 연습 2
relplot을 사용해 scatter plot을 그리고 값 별 size를 설정할 수 있다.
# Import Matplotlib and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
# Create scatter plot of horsepower vs. mpg
sns.relplot(x="horsepower", y="mpg", data=mpg,
kind="scatter", size="cylinders", hue="cylinders")
# Show plot
plt.show()
- 연습 3
# Import Matplotlib and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
# Create a scatter plot of acceleration vs. mpg
sns.relplot(x="acceleration", y="mpg", data=mpg
, kind="scatter", hue="origin", style = "origin")
# Show plot
plt.show()
- 슬라이드 출처
Creating subplots with col and row | Python
campus.datacamp.com
'👩🏻💻 DataScientist for Python > DataCamp' 카테고리의 다른 글
for loop (0) | 2022.11.15 |
---|---|
Python Data Science Toolbox 1 - def function (0) | 2022.11.08 |
Introduction to Data Visualization with Seaborn 1 (0) | 2022.10.24 |
Data Visualization with Matplotlib 4 - Annotating time-series data (0) | 2022.10.18 |
Data Visualization with Matplotlib 3 - Plotting time-series data (0) | 2022.10.18 |