산점도(Scatter Plot)¶
์ค๋์ ์ฐ์ ๋๋ฅผ ๊ทธ๋ ค๋ณผ๋ ค๊ณ ํ๋ค.
In [40]:
# ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฐ์ ธ์ค๊ธฐ
import pandas as pd
import pyecharts.options as opts
from pyecharts.charts import Scatter
์ด๋ฒ์๋ ๊ฐ๋ณ๊ฒ ๊ทธ๋ ค๋ณผ ์์ ์ด๊ธฐ ๋๋ฌธ์ ๋ฐ์ดํฐ๋ ์์ ๊ฑธ๋ก ๊ฐ์ ธ์๋ค.
๋๋ฌด์ํค(https://namu.wiki/w/2021%20LoL%20Champions%20Korea%20Spring)์์ 2021๋ LCK Spring, Summer์ PoG ์ ์ ๋ฐ์ดํฐ๋ค.
๋๋ ์์ ์ ํ๋ํ๋ ์ ์๋ค.
In [3]:
data = pd.read_excel("LCK_PoG.xlsx")
In [4]:
data
Out[4]:
In [14]:
# ๊ฐ ๋ฐ์ดํฐ๋ค์ ๋ฆฌ์คํธ ํํ๋ก ๋ณ๊ฒฝ
x = list(data["Name"])
y = list(data["Summer PoG Points"])
z = list(data["Spring PoG Points"])
team = list(data["Team"])
๊ธฐ๋ณธ์ ์ธ ์ฐ์ ๋๋ฅผ ๊ทธ๋ฆฌ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ๋ค.
In [10]:
scatter = (
Scatter()
.add_xaxis(x)
.add_yaxis("2021๋
LCK Summer PoG Points", y)
.set_global_opts(title_opts = opts.TitleOpts(title="๋ฆฌ๊ทธ ์ค๋ธ ๋ ์ ๋"))
.render_notebook()
)
scatter
Out[10]:
์ฌ๊ธฐ์ ๊ฐ๋ณ๋ก ๋ค๋ฅธ ์์์ ์ง์ ํด ์ค ์๋ ์๋ค.
In [19]:
scatter = (
Scatter()
.add_xaxis(x)
.add_yaxis("2021๋
LCK Summer PoG Points", y)
.set_global_opts(title_opts = opts.TitleOpts(title="๋ฆฌ๊ทธ ์ค๋ธ ๋ ์ ๋"),
visualmap_opts = opts.VisualMapOpts(max_=1200)) # max_ ๊ฐ์ ๋ฐ๋ผ ์์์ด ๋ค๋ฅด๊ฒ ์ง์ ๋๋ค.
.render_notebook()
)
scatter
Out[19]:
๊ทธ๋ํ๊ฐ ์ฌ์ฌํด ๋ณด์ธ๋ค๋ฉด ๊ฒฉ์๋ฅผ ์ถ๊ฐํด ์ค ์๋ ์๋ค.
In [12]:
scatter = (
Scatter()
.add_xaxis(x)
.add_yaxis("2021๋
LCK Summer PoG Points", y)
.set_global_opts(title_opts = opts.TitleOpts(title="๋ฆฌ๊ทธ ์ค๋ธ ๋ ์ ๋"),
xaxis_opts = opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True)), # x์ถ ๊ฒฉ์ on
yaxis_opts = opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True))) # y์ถ ๊ฒฉ์ on
.render_notebook()
)
scatter
Out[12]:
์ฐ์ ๋๋ฅผ ์ฌ๋ฌ ๊ฐ ๊ทธ๋ฆฌ๊ณ ์ถ๋ค๋ฉด, ๋ง๋ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ ธ์ ๋์ฒ๋ผ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋๋ค.
In [15]:
scatter = (
Scatter()
.add_xaxis(x)
.add_yaxis("2021๋
LCK Summer PoG Points", y)
.add_yaxis("2021๋
LCK Spring PoG Points", z) # 2021๋
Spring ์ฐ์ ๋๋ฅผ ์ถ๊ฐ
.set_global_opts(title_opts = opts.TitleOpts(title="๋ฆฌ๊ทธ ์ค๋ธ ๋ ์ ๋"))
.render_notebook()
)
scatter
Out[15]:
๊ฐ๋ค๋ณ๋ก ์ค์๋๋ฅผ ๋ค๋ฅด๊ฒ ๋ณด์ฌ์ค ์๋ ์๋ค.
In [17]:
scatter = (
Scatter()
.add_xaxis(x)
.add_yaxis("2021๋
LCK Summer PoG Points", y)
.add_yaxis("2021๋
LCK Spring PoG Points", z)
.set_global_opts(title_opts = opts.TitleOpts(title="๋ฆฌ๊ทธ ์ค๋ธ ๋ ์ ๋"),
visualmap_opts = opts.VisualMapOpts(type_="size", max_=1200, min_=200)) # max_, min_ ๊ฐ์ ๋ฐ๋ผ ํฌ๊ธฐ๊ฐ ๋ณ๊ฒฝ
.render_notebook()
)
scatter
Out[17]:
In [ ]: