import plotly.express as px
="displ", y="hwy", color="drv", trendline="lowess") px.scatter(mpg, x
Alternative plots
R for Data Science by Wickham & Grolemund
Fitted lines
alternatives: plotly
, seaborn
Plotly
다음과 같이 smoothing parameter를 지정할 수 있음
자세한 옵션은 여기 참조: plotly linear fits
(="displ", y="hwy", color="drv",
px.scatter(mpg, x="lowess", trendline_options=dict(frac=0.3)) # smoothing parameter
trendline=600, height=500)
.update_layout(width )
(="bill_length_mm", y="bill_depth_mm", color="species",
px.scatter(penguins, x="lowess", trendline_options=dict(frac=0.5),
trendline="island", # faceting
facet_col=0.5) # alpha
opacity=900, height=400)
.update_layout(width )
Seaborn: lmplot()
="displ", y="hwy", hue="drv", # color대신 hue
sns.lmplot(mpg, x=True,
lowess={"alpha":.5, "s":20}, # s: point size
scatter_kws=3, aspect=5/3)
height# 생략해도 무방 plt.show()
= sns.load_dataset("penguins")
penguins
="bill_length_mm", y="bill_depth_mm", hue="species",
sns.lmplot(penguins, x=True,
lowess="sex", # faceting: col, row
col=3, scatter_kws={"alpha":.5, "s":5}) height
Box plot
= sns.load_dataset("penguins") penguins
import plotly.express as px
=["sex"]), x="species", y="bill_length_mm", color="island", facet_col="sex") px.box(penguins.dropna(subset
Unable to display output for mime type(s): application/vnd.plotly.v1+json
= sns.load_dataset("penguins")
penguins
sns.catplot(=penguins, x="species", y="bill_length_mm", hue="sex", col="island",
data="box", height=4, aspect=.6,
kind
) plt.show()