2025-05-29

장상희·2025년 5월 29일
0

파이썬

목록 보기
27/31

Plotly 타이틀 설정하기

fig.update_layout(title_text="타이틀 입력")
#이것은 기존에 있는 fig라는 그래프에 타이틀을
#업데이트 한것으로 이걸로 express,graph 두가지 방식 모두 커버 가능하다

위치 지정

fig.update_layout(
            title_x = (0~1) 사이값#x좌표
            title_y = (0~1) 사이값#y좌표
            title_xanchor = (`auto","left","center","right")#좌표를 중심으로 타이틀을 왼쪽, 또는 가운데, 오른쪽에 놓을지 설정합니다.
            title_yanchor = ("auto","top","middle","bottom")#title_yanchor = 좌표를 중심으
            })

Plotly 축 타이틀 설정하기(Axes Title)

graph_object 그래프

fig.update_xaxes(title_text='X축 타이틀명')#x축에 삽입할 타이틀명을 업데이트 한다
fig.update_yaxes(title_text='Y축 타이틀명')#축만 바뀌지 위와 같다ㅣ

축 타이틀 스타일 설정방법


fig.update_xaxes(title_font_size =30,
                 title_font_color='crimson',
                 title_font_family='Courier')
fig.update_yaxes(title_font_size =30,
                 title_font_color='crimson',
                 title_font_family='Courier')

축의 타이틀도 글자크기, 색, 폰트변경이 똑같이 가능하다

축 타이틀 위치 지정방법

fig.update_xaxes(title_standoff= 100)#x축 타이틀의 위치간격을 업데이트할 수 있다
fig.update_yaxes(title_standoff= 100)#
fig.update_xaxes(title=None)#축에 있는 레이블삭제
fig.update_yaxes(title=None)

Plotly 축 범위 지정하기

fig.update_xaxes(range=[min, max])#최소값 최대값으로 축 범위 지정
fig.update_yaxes(range=[min, max])

축 범위 역방향으로 지정하기

fig.update_xaxes(autorange="reversed")#x좌표 레이어 역방향으로 반전시키기
fig.update_yaxes(autorange="reversed")

Log 스케일 지정하기,

# 축 Log 스케일로 변환
fig.update_xaxes(type="log")
fig.update_yaxes(type="log")
facet_col="species"#facet_col 열로 나눠준다( species = 종),열 방향으로 종을 기준으로 나눠준다
profile
프로그래머 꿈나무

0개의 댓글