본문 바로가기

👩🏻‍💻 DataScientist for Python/DataCamp

Introduction to Data Visualization with Seaborn 2

- 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()

- 슬라이드 출처

https://campus.datacamp.com/courses/introduction-to-data-visualization-with-seaborn/visualizing-two-quantitative-variables?ex=2 

 

Creating subplots with col and row | Python

 

campus.datacamp.com