본문 바로가기

728x90

Data Visualization

(7)
[Matplotlib / Seaborn] 한글 깨짐 문제 해결 matplotlib 또는 Seaborn 으로 한글로 된 데이터를 시각화 하면 아래 사진과 같이 한글이 깨져서 나오는 경우가 종종 있습니다. 이 경우 아래와 같이 내 컴퓨터에 설치된 폰트 리스트를 확인하면 설치된 한글 폰트 확인 import matplotlib.font_manager as fm font_list = [font.name for font in fm.fontManager.ttflist] font_list 내 컴퓨터에 설치된 폰트를 확인 할 수 있고, 이중 원하시는 폰트를 아래과 같이 적용하여 사용하시면 됩니다. Window OS plt.rcParams['font.family'] = 'NanumGothic' Mac OS plt.rcParams['font.family'] = 'AppleGothic'..
[plotly] annotation(주석) 넣기 참고 사이트: https://plotly.com/python/text-and-annotations/ 상세 옵션: https://plotly.com/python/reference/#layout-annotations import plotly.graph_objects as go fig = go.Figure() fig.add_trace( go.Bar( x=merged_order_month_sum_from2017.index, y=merged_order_month_sum_from2017['payment_value'], text=merged_order_month_sum_from2017['payment_value'], textposition='auto', texttemplate='R$ %{y:,.0f}', marker..
[plotly] bar chart 색깔 바꾸기 # 색상 설정 colors = ['#03588C',] * len(merged_order_month_sum_from2017.index) colors[10] = '#F24472' import plotly.graph_objects as go fig = go.Figure() fig.add_trace( go.Bar( x=merged_order_month_sum_from2017.index, y=merged_order_month_sum_from2017['payment_value'], text=merged_order_month_sum_from2017['payment_value'], textposition='auto', texttemplate='R$ %{text:,.0f}', marker_color=colors # 색상..
[plotly] plotly.graph_objects 로 차트 그리기 라이브러리 로드 import plotly.graph_objects as go import plotly.offline as pyo pyo.init_notebook_mode() 기본그리기 차트 종류는 아래 사이트에서 확인 할 수 있습니다. Basic Chart : https://plotly.com/python/basic-charts/ Statistical Chart : https://plotly.com/python/statistical-charts/ fig = go.Figure() fig.add_trace( go.Bar( x = df.index, y = df["A"] ) ) fig.show() 다중 그래프 그리기 fig = go.Figure() fig.add_trace( go.Bar( x = df.index..
[plotly] iplot 차트 세부 요소 변경 하기 라이브러리 로드 import chart_studio.plotly as py import cufflinks as cf cf.go_offline(connected=True) x 축, y 축, 차트 타이틀 설정 df.iplot(kind = "line", xTitle = "X title", # x 축 타이틀 yTitle = "Y title", # y 축 타이틀 title = "title name" # 차트 타이틀 ) 차트 테마 변경 cf.getThemes() 위와 같이 총 7개의 테마를 확인 할 수 있습니다. themes = cf.getThemes() for theme_item in themes: df.iplot(kind = "line", theme = theme_item, xTitle = "X title", ..
[plotly] iplot 으로 line chart 그리기 라이브러리 로드 import chart_studio.plotly as py import cufflinks as cf cf.go_offline(connected = True) line chart 그리기 df.iplot(kind = "line") kind 에 line 대신 scatter 를 사용해도 동일한 line chart 가 그려집니다. (mode 등 세부사항도 동일하게 적용 됩니다.) df.iplot(kind = "scatter") line chart mode : lines (default) df.iplot(kind = "line", mode = "lines) line chart mode : markers df.iplot(kind = "line", mode = "markers") line chart m..
[plotly] iplot 으로 bar chart 그리기 라이브러리 로드 import chart_studio.plotly as py import cufflinks as cf cf.go_offline(connected=True) bar chart 그리기 df.iplot(kind = "bar") bar chart mode : group (default) df.iplot(kind = "bar", barmode = "group") bar chart mode : stack (누적 그래프) df.iplot(kind = "bar", barmode = "stack") bar chart mode : overay (겹쳐서 그리기) df.iplot(kind = "bar", barmode = "overlay") Series 로 bar chart 그리기 df["A"].iplot(ki..

728x90