๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”

Plotly - ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„

by ํฌ๋ฆฌ๋„ฅ์Šค์„๋ผ์ด์Šค 2021. 8. 19.

 

 
image1

Plotly

ํŒŒ์ด์ฌ์„ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ ๋ถ„์„์„ ํ•˜๋ฉด์„œ matplotlib, seaborn์œผ๋กœ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ฐ€์žฅ ๋งŽ์ด ๊ทธ๋ ธ๋‹ค. ์ด๋•Œ๋Š” ์ด ๋‘ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ด์™ธ์—๋Š” ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆด ์ˆ˜ ์žˆ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์žˆ๋‹ค๊ณ ๋Š” ์ƒ๊ฐ์„ ๋ชป ํ–ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค. ๊ทธ๋Ÿฌ๋‹ค 2021๋…„ ์ดˆ์— ์ธํ„ด์ด ๋๋‚˜๊ณ  ์ง‘์—์„œ ๋†€๊ณ  ์žˆ์„ ๋•Œ ์šฐ์—ฐํžˆ Plotly, Bokeh ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์„ ์•Œ๊ฒŒ ๋˜์—ˆ๊ณ , ๊ทธ๋ž˜ํ”„๊ฐ€ ์˜ˆ์˜๊ฒŒ ๊ทธ๋ ค์ง€๋‹ˆ๊น ํ™•์‹คํžˆ ๋” ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ๋Š” ๋ง›์ด ์ƒ๊ฒผ๋‹ค.

Plotly๋กœ ๊ทธ๋ฆด ์ˆ˜ ์žˆ๋Š” ๊ทธ๋ž˜ํ”„์— ๋Œ€ํ•œ ์ •๋ณด๋Š” https://plotly.com/python/ ์ด๊ณณ์—์„œ ๋” ์ฐพ์•„๋ณผ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ง€๊ธˆ์€ ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ ค๋ณด๊ณ ์ž ๊ธฐ๋ก์„ ๋‚จ๊ธด๋‹ค.

 

Plotly ์„ค์น˜ํ•˜๊ธฐ

In [ ]:
# plotly ์„ค์น˜ํ•˜๊ธฐ
pip install plotly
In [ ]:
# ์„ค์น˜ํ•˜๋ฉด์„œ ๋ฒ„์ „์„ ์ง€์ •ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.
pip install plotly==5.2.1
In [ ]:
# pip ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด ์„ค์น˜๋œ plotly ๋ฒ„์ „ ์—…์„ ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.
pip install plotly --upgrade
 

๋งŒ์•ฝ conda prompt์—์„œ ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค๋ฉด conda install plotly ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

In [6]:
import plotly

print("Plotly ๋ฒ„์ „ :", plotly.__version__)
 
Plotly ๋ฒ„์ „ : 5.1.0
 

๋จผ์ € ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ ๋ฐ์ดํ„ฐ๋Š” ํ†ต๊ณ„์ฒญ(https://kosis.kr/index/index.do)์—์„œ ์ธ๊ตฌ ์ด ์กฐ์‚ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ด์šฉํ–ˆ๋‹ค.

image.png

์ด ๋ฐ์ดํ„ฐ์—์„œ 2020๋…„ ์ด์ธ๊ตฌ, ๋‚จ์ž์ธ๊ตฌ, ์—ฌ์ž์ธ๊ตฌ๋ฅผ ์‹œ๋„๋ณ„๋กœ ๊ฐ€์ ธ์™”๋‹ค.

 
image.png
In [1]:
# ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ 
import pandas as pd
import plotly.express as px
In [2]:
# 2020๋…„ ์ธ๊ตฌ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
data = pd.read_excel("2020๋…„ ์ธ๊ตฌ.xlsx")
In [3]:
data.head(5)
Out[3]:
  ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™) 2020 2020.1 2020.2
0 ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™) ์ด์ธ๊ตฌ (๋ช…) ๋‚จ์ž (๋ช…) ์—ฌ์ž (๋ช…)
1 ์ „๊ตญ 51829136 25915207 25913929
2 ์„œ์šธํŠน๋ณ„์‹œ 9586195 4647733 4938462
3 ๋ถ€์‚ฐ๊ด‘์—ญ์‹œ 3349016 1638751 1710265
4 ๋Œ€๊ตฌ๊ด‘์—ญ์‹œ 2410700 1190271 1220429
 

์—‘์…€ ๋ฐ์ดํ„ฐ๋ฅผ ๊ทธ๋ƒฅ ๊ฐ€์ ธ์˜ค๋ฉด 0๋ฒˆ์งธ ํ–‰์—๋„ ์ปฌ๋Ÿผ์˜ ์ด๋ฆ„์ด ๋“ค์–ด๊ฐ€๊ธฐ ๋•Œ๋ฌธ์— ์˜ต์…˜์œผ๋กœ header = 1์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

์•„๋‹ˆ๋ฉด ์—‘์…€๋กœ ์—ด์–ด์„œ ์œ„์ชฝ ๋ถ€๋ถ„์„ ์ˆ˜์ •ํ•ด๋„ ๋œ๋‹ค.

In [4]:
# 2020๋…„ ์ธ๊ตฌ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
data = pd.read_excel("2020๋…„ ์ธ๊ตฌ.xlsx", header = 1)
In [5]:
data.head(5)
Out[5]:
  ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™) ์ด์ธ๊ตฌ (๋ช…) ๋‚จ์ž (๋ช…) ์—ฌ์ž (๋ช…)
0 ์ „๊ตญ 51829136 25915207 25913929
1 ์„œ์šธํŠน๋ณ„์‹œ 9586195 4647733 4938462
2 ๋ถ€์‚ฐ๊ด‘์—ญ์‹œ 3349016 1638751 1710265
3 ๋Œ€๊ตฌ๊ด‘์—ญ์‹œ 2410700 1190271 1220429
4 ์ธ์ฒœ๊ด‘์—ญ์‹œ 2945454 1477064 1468390
 

๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„

๋จผ์ € ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ฐ ์ง€์—ญ๋ณ„ ์ด ์ธ๊ตฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„๋กœ ๊ทธ๋ ค๋ณธ๋‹ค.

In [6]:
fig = px.bar(data,                      # ๊ทธ๋ž˜ํ”„์— ์“ฐ์ผ ๋ฐ์ดํ„ฐ
             x='ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)',    # x์ถ•
             y='์ด์ธ๊ตฌ (๋ช…)',           # y์ถ•
             title = "2020๋…„ ์ด์ธ๊ตฌ")   # ์ œ๋ชฉ 

fig.show()
 
 
 
 

px.bar๋กœ ๊ธฐ๋ณธ์ ์ธ ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆด ์ˆ˜ ์žˆ์ง€๋งŒ ๋ง‰๋Œ€์˜ ์ƒ‰์„ ๋ฐ”๊พผ๋‹ค๊ฑฐ๋‚˜, ๋ˆ„์ ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ๊ฑฐ๋‚˜ ํ•  ๋•Œ ์ถ”๊ฐ€์ ์ธ ์˜ต์…˜๋“ค์„ ์“ธ ๋•Œ๋Š” graph_objects๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฒƒ ๊ฐ™์•„ graph_objects๋ฅผ ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

In [7]:
import plotly.graph_objects as go

fig = go.Figure(data=[
    go.Bar(name = '2020๋…„ ์—ฌ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["์—ฌ์ž (๋ช…)"]), # ๊ฐ๊ฐ ๊ทธ๋ž˜ํ”„ ์ด๋ฆ„, x์ถ•, y์ถ•
    go.Bar(name = '2020๋…„ ๋‚จ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["๋‚จ์ž (๋ช…)"])
])

# ๊ทธ๋ž˜ํ”„์˜ ๋ชจ์Šต์„ group๋ฅผ ์ง€์ •ํ•˜๋ฉด ๋‘ ๊ฐœ๋ฅผ ์—ฐ๋‹ฌ์•„ ๊ทธ๋ ค์ค€๋‹ค.
fig.update_layout(barmode = 'group')   
fig.show()
 
 
 

go.Bar()์— marker_color ์˜ต์…˜์„ ์ด์šฉํ•˜๋ฉด ๊ฐ ๋ง‰๋Œ€์˜ ์ƒ‰์ƒ์„ ๋ฐ”๊พธ๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค. ๋‚˜๋Š” http://www.w3big.com/ko/tags/html-colorname.html ์ด๊ณณ์—์„œ ์ƒ‰์ƒ์˜ ์ด๋ฆ„๊ณผ ์ƒ‰์„ ๋ณด๊ณ  ๋ง˜์— ๋“œ๋Š” ์ƒ‰์ƒ์„ ๊ณจ๋ผ์„œ ์‚ฌ์šฉํ–ˆ๋‹ค.

In [8]:
fig = go.Figure(data=[
    go.Bar(name = '2020๋…„ ์—ฌ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["์—ฌ์ž (๋ช…)"], marker_color = 'PowderBlue'),
    go.Bar(name = '2020๋…„ ๋‚จ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["๋‚จ์ž (๋ช…)"], marker_color = 'LightCoral')
])

fig.update_layout(barmode = 'group')   # ๊ทธ๋ž˜ํ”„์˜ ๋ชจ์Šต์„ group๋ฅผ ์ง€์ •ํ•˜๋ฉด ๋‘ ๊ฐœ๋ฅผ ์—ฐ๋‹ฌ์•„ ๊ทธ๋ ค์ค€๋‹ค.
fig.show()
 
 
 

์ง€๊ธˆ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” x์ถ•์˜ ๋ˆˆ๊ธˆ์˜ ํ…์ŠคํŠธ๊ฐ€ ๊ธธ์–ด์„œ ์ƒ๊ด€ ์—†์ง€๋งŒ, 45๋„ ์ •๋„๋กœ ๊ธฐ์šธ์ธ x์ถ• ๊ฐ’๋“ค์ด ์‹ซ์€ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿด ๋•Œ๋Š” update_layout()์—์„œ xaxis_tickangle ์˜ต์…˜์— ๊ฐ๋„๋ฅผ ์„ค์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

In [9]:
fig = go.Figure(data=[
    go.Bar(name = '2020๋…„ ์—ฌ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["์—ฌ์ž (๋ช…)"]), # ๊ฐ๊ฐ ๊ทธ๋ž˜ํ”„ ์ด๋ฆ„, x์ถ•, y์ถ•
    go.Bar(name = '2020๋…„ ๋‚จ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["๋‚จ์ž (๋ช…)"])
])

fig.update_layout(barmode = 'group',    # ๊ทธ๋ž˜ํ”„์˜ ๋ชจ์Šต์„ group๋ฅผ ์ง€์ •ํ•˜๋ฉด ๋‘ ๊ฐœ๋ฅผ ์—ฐ๋‹ฌ์•„ ๊ทธ๋ ค์ค€๋‹ค.
                  xaxis_tickangle=-45)  # x์ถ•์˜ ๋ˆˆ๊ธˆ์˜ ๊ฐ๋„๋ฅผ ์กฐ์ •ํ•ด์„œ ์›ํ•˜๋Š” ๋ชจ์Šต์œผ๋กœ ์ถœ๋ ฅํ•  ์ˆ˜๋„ ์žˆ๋‹ค. 
fig.show()
 
 
 

์œ„์—์„œ ๋‘ ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„๋ฅผ ์—ฐ๋‹ฌ์•„์„œ ๊ทธ๋ ธ๋‹ค๋ฉด ๋‹น์—ฐํžˆ ๊ฒน์ณ์„œ ๊ทธ๋ ค๋ณด๊ณ  ์‹ถ๊ธฐ๋„ ํ•˜๋‹ค. ์ด๋Ÿด ๋•Œ๋Š” barmode ์˜ต์…˜์„ group์ด ์•„๋‹Œ stack์œผ๋กœ ๋ฐ”๊ฟ”์ฃผ๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.

In [10]:
fig = go.Figure(data=[
    go.Bar(name = '2020๋…„ ์—ฌ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["์—ฌ์ž (๋ช…)"]), # ๊ฐ๊ฐ ๊ทธ๋ž˜ํ”„ ์ด๋ฆ„, x์ถ•, y์ถ•
    go.Bar(name = '2020๋…„ ๋‚จ์ž ์ธ๊ตฌ', x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], y = data["๋‚จ์ž (๋ช…)"])
])

fig.update_layout(barmode = 'stack')      # ๊ทธ๋ž˜ํ”„์˜ ๋ชจ์Šต์„ stack์„ ์ง€์ •ํ•˜๋ฉด ๋‘ ๊ฐœ๋ฅผ ๋ˆ„์ ํ•ด์„œ ๊ทธ๋ ค์ค€๋‹ค.
fig.show()
 
 
 

๋งŒ์•ฝ ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์œ„์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ค์„œ ํ•ด๋‹น ๊ฐ’์„ ํ™•์ธํ•˜๋Š”๊ฒŒ ๊ท€์ฐฎ๋‹ค๋ฉด, ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„ ์œ„์— ํ•ด๋‹น ๊ฐ’์„ ํ…์ŠคํŠธ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

In [11]:
fig = go.Figure(data=[
    go.Bar(name = '2020๋…„ ์ด ์ธ๊ตฌ', 
           x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], 
           y = data["์ด์ธ๊ตฌ (๋ช…)"], 
           marker_color = 'LightSteelBlue', 
           text = data["์ด์ธ๊ตฌ (๋ช…)"])      # ํ…์ŠคํŠธ๋กœ ํ‘œํ˜„ํ•  ๊ฐ’์„ ์ง€์ • - ์—ฌ๊ธฐ์„  y์ถ•๊ณผ ๋™์ผ 
])

fig.show()
 
 
 

์ถœ๋ ฅ๋˜๋Š” ํ…์ŠคํŠธ๊ฐ€ ์—‰๋ง์ง„์ฐฝ์ด๋‹ค. ์–ด๋–ค ๊ฑฐ๋Š” ์„ธ๋กœ๋กœ ์ถœ๋ ฅ๋˜๊ณ , ๊ฐ€๋กœ๋กœ ์ถœ๋ ฅ๋˜๊ณ , ํ…์ŠคํŠธ ํฌ๊ธฐ๋„ ์ œ๋ฉ‹๋Œ€๋กœ.....

์ด๋Ÿด ๋•Œ๋Š” ๋ ˆ์ด์•„์›ƒ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์„ค์ •ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.

In [12]:
fig = go.Figure(data=[
    go.Bar(name = '2020๋…„ ์ด ์ธ๊ตฌ', 
           x = data["ํ–‰์ •๊ตฌ์—ญ๋ณ„(์๋ฉด๋™)"], 
           y = data["์ด์ธ๊ตฌ (๋ช…)"], 
           marker_color = 'LightSteelBlue', 
           text = data["์ด์ธ๊ตฌ (๋ช…)"])      # ํ…์ŠคํŠธ๋กœ ํ‘œํ˜„ํ•  ๊ฐ’์„ ์ง€์ • - ์—ฌ๊ธฐ์„  y์ถ•๊ณผ ๋™์ผ 
])

fig.update_traces(texttemplate='%{text:.2s}',  # ํ‘œ์‹œ๋  ํ…์ŠคํŠธ์˜ ํ˜•ํƒœ ์ง€์ •
                  textposition='outside')      # ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„ ๋ฐ–์— ํ…์ŠคํŠธ ์ถœ๋ ฅ

# ํ…์ŠคํŠธ ํฌ๊ธฐ๋ฅผ ๋ชจ๋‘ ๊ฐ™๊ฒŒ ์ถœ๋ ฅํ•˜๊ณ  ์‹ถ์œผ๋ฉด ์ด ๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•œ๋‹ค. 
fig.update_layout(uniformtext_minsize=8,       # ์ตœ์†Œ ๊ธ€๊ผด ํฌ๊ธฐ ์„ค์ •
                  uniformtext_mode='hide')     # ๊ธ€๊ผด ํฌ๊ธฐ์— ๋งž์ง€ ์•Š๋Š” ๋ ˆ์ด๋ธ”์— ๋Œ€ํ•ด ์ˆ˜ํ–‰ํ•  ์ž‘์—…์„ ์„ค์ •->show(์˜ค๋ฒ„ํ”Œ๋กœ์šฐ ํ‘œ์‹œ),hide(์ˆจ๊น€)

fig.show()
 
 
 

์ด๋ฒˆ์—๋Š” ๊ฐ„๋žตํ•˜๊ฒŒ ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ๊ธฐ๋Šฅ์„ ๋‹ค๋ค„๋ณผ๋ ค๊ณ  ํ•œ๋‹ค. 2020๋…„ ๋ฆฌ๊ทธ ์˜ค๋ธŒ ๋ ˆ์ „๋“œ LCK Spring PoG ์ ์ˆ˜์™€ 2021๋…„ ๋ฆฌ๊ทธ ์˜ค๋ธŒ ๋ ˆ์ „๋“œ LCK Summer PoG ์ ์ˆ˜๋ฅผ ํ•œ ๋ฒˆ ์‚ฌ์šฉํ•ด๋ณธ๋‹ค.

image.png
In [13]:
# 2021๋…„ LCK Spring Player of the Game(PoG)
players = ["ShowMaker", "Pyosik", "Chovy", "Keria", "Khan", "Canyon"]
points_21 = [1000, 1000, 1000, 900, 800, 700]

# 2020๋…„ LCK Summer Player of the Game(PoG)
points_20 = [1100, 300, 1000, 800, 0, 1000]
In [14]:
colors = ['lightslategray',] * 6   # ์ƒ‰์ƒ์„ ๋‹ด์€ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
colors[0] = 'crimson'              # ๋ฆฌ์ŠคํŠธ์˜ ์ฒซ ๋ฒˆ์งธ ์ƒ‰์ƒ๋งŒ cromsom์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.

fig = go.Figure(data=[go.Bar(
    x = players,
    y = points_21,
    marker_color = colors       # ๋ฆฌ์ŠคํŠธ๋ฅผ ์ƒ‰์ƒ์œผ๋กœ ์ง€์ •ํ•œ๋‹ค.
)])

fig.update_layout(title_text='2021 LCK Spring PoG')
 
 
In [15]:
colors = ['lightslategray',] * 6
colors[0] = 'crimson'

fig = go.Figure(data=[go.Bar(
    x = players,
    y = points_20,
    marker_color = colors
)])

fig.update_layout(title_text='2020 LCK Summer PoG')
 
 
 

๋ง‰๋Œ€๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ๋‹ค๋ณด๋ฉด ์ฃผ์‹ ์ฐจํŠธ์ฒ˜๋Ÿผ ๋“ฑ๋ฝ๋ฅ ? ๊ฐ™์ด ํ‘œํ˜„ํ•˜๊ณ  ์‹ถ์„ ๋•Œ๋„ ์žˆ๋‹ค. ๊ทธ๋Ÿด ๋•Œ๋Š” base ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

In [16]:
fig = go.Figure()
fig.add_trace(go.Bar(x = players, 
                     y = points_20,
                     base = [-1100, -300, -1000, -800, 0, -1000],   # ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„์˜ ๊ธฐ์ค€์„ ์„ค์ •ํ•ด์ค„ ์ˆ˜ ์žˆ๋‹ค. -> 0์— ๊ฑธ์น˜๋„๋ก
                     marker_color='crimson',
                     name='2020 Spring'))
fig.add_trace(go.Bar(x = players, 
                     y = points_21,
                     base=0,
                     marker_color='lightslategrey',
                     name='2021 Summer'))

fig.show()
 
 
 

๊ฐ๊ฐ์˜ ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„ ๋„“์ด๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฒƒ ๋˜ํ•œ ๊ฐ€๋Šฅํ•˜๋‹ค.

In [17]:
fig = go.Figure(data=[go.Bar(
    x = players,
    y = points_21,
    width = [1, 1, 1, 0.7, 0.5, 0.3] # ๊ฐ ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„์˜ ๋„“์ด๋ฅผ ๋ฆฌ์ŠคํŠธ์— ๋„ฃ์–ด์„œ ์ฃผ๋ฉด ๋œ๋‹ค.
)])

fig.show()
 
 
In [ ]: