Plotly로 주가 데이터를 시계열에 맞춰 그릴 때,
y축의 단위가 '원' 같은 경우 1000원을 넘어가면 k로 표현되어 곤란했다.
이때, update_layout의 yaxis_tickformat을 사용하면 000으로 표현할 수 있을 뿐만 아니라 표현식을 변경할 수도 있다!
import plotly.graph_objects as go
from plotly.subplots import make_subplots # subplot 위한 import
fig = make_subplots(rows=1, cols=1)
fig = go.Figure(data=[go.Scatter(x=sp[dict_name['삼성전자']]['date'], y=sp[dict_name['삼성전자']]['close'])])
fig.update_layout(
autosize=False,
width=1000,
height=500,
yaxis_tickformat='f'
)
fig.show()
'컴퓨터이야기 > Python' 카테고리의 다른 글
[Python] 아나콘다 (Anaconda) env 생성, 삭제 (0) | 2020.10.30 |
---|---|
[Python] 지정 경로에 폴더 존재 확인 및 생성 (0) | 2020.10.28 |