Data Science
[Matplotlib] 축레이블 여러줄로 변환 | 줄바꿈
오기오기
2024. 6. 4. 19:21
728x90
x-label이 너무 길어서 여러줄로 줄바꿈을 하고싶을때
아래 코드를 사용해보세요
from textwrap import wrap
df['location'] = ['\n'.join(wrap(x, 12)) for x in df['location']]
df
df['location'] = df['location'].apply(lambda x: '\n'.join(wrap(x, 12)))
이렇게 데이터 프레임안에 12번째 마다 \n이 중간에 들어가게되는데
plot을 그렸을때 자동적으로 줄 바꿈을 하라고 인식하게 됩니다
질문있으시면 댓글남겨주세요:)
728x90
반응형