묻고 답해요
141만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결파이썬 증권 데이터 수집과 분석으로 신호와 소음 찾기
데이터 시각화 도구 소개와 한글폰트 설정 에러
데이터 시각화 도구 소개와 한글폰트 설정 에러 위에 강좌를 실습 중에 에러가 발생합니다. 우분투, 주피터노트북 사용, 나눔바른고딕 폰트 있습니다. 도와주세요!!!! 1. 우분투에 나눔바른고딕 폰트 있음: 제가 실습하는 환경 (base) root@gd-virtual-machine:/usr/share/fonts/truetype/nanum# lsb_release -d Description: Ubuntu 20.04.4 LTS (base) root@gd-virtual-machine:/usr/share/fonts/truetype/nanum# (base) root@gd-virtual-machine:/usr/share/fonts/truetype/nanum# (base) root@gd-virtual-machine:/usr/share/fonts/truetype/nanum# ls NanumBarunGothic.ttf NanumBarunGothic.ttf (base) root@gd-virtual-machine:/usr/share/fonts/truetype/nanum# 2. 에러 발생(강의 코드) def get_font_family(): import platform system_name = platform.system() if system_name == "Darwin" : font_family = "AppleGothic" elif system_name == "Windows": font_family = "Malgun Gothic" else: import matplotlib.font_manager as fm fontpath = '/usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf' font = fm.FontProperties(fname=fontpath, size=9) fm._rebuild() font_family = "NanumBarunGothic" return font_family AttributeError Traceback (most recent call last) /tmp/ipykernel_1662/385091406.py in <module> ----> 1 get_font_family() /tmp/ipykernel_1662/3056356644.py in get_font_family() 11 fontpath = '/usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf' 12 font = fm.FontProperties(fname=fontpath, size=9) ---> 13 fm._rebuild() 14 font_family = "NanumBarunGothic" 15 return font_family AttributeError: module 'matplotlib.font_manager' has no attribute '_rebuild' 3. 에러 발생(수업자료 소스 코드) def get_font_family(): """ 시스템 환경에 따른 기본 폰트명을 반환하는 함수 """ import platform system_name = platform.system() if system_name == "Darwin" : font_family = "AppleGothic" elif system_name == "Windows": font_family = "Malgun Gothic" else: # Linux(colab) !apt-get install fonts-nanum -qq > /dev/null !fc-cache -fv import matplotlib as mpl mpl.font_manager._rebuild() findfont = mpl.font_manager.fontManager.findfont mpl.font_manager.findfont = findfont mpl.backends.backend_agg.findfont = findfont font_family = "NanumBarunGothic" return font_family /usr/share/fonts: caching, new cache contents: 0 fonts, 6 dirs /usr/share/fonts/X11: caching, new cache contents: 0 fonts, 4 dirs /usr/share/fonts/X11/Type1: caching, new cache contents: 8 fonts, 0 dirs /usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs /usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/X11/misc: caching, new cache contents: 89 fonts, 0 dirs /usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/cMap: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs /usr/share/fonts/cmap/adobe-cns1: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/cmap/adobe-gb1: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/cmap/adobe-japan1: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/cmap/adobe-japan2: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/cmap/adobe-korea1: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/opentype: caching, new cache contents: 0 fonts, 3 dirs /usr/share/fonts/opentype/malayalam: caching, new cache contents: 7 fonts, 0 dirs /usr/share/fonts/opentype/noto: caching, new cache contents: 28 fonts, 0 dirs /usr/share/fonts/opentype/urw-base35: caching, new cache contents: 35 fonts, 0 dirs /usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 50 dirs /usr/share/fonts/truetype/Gargi: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/Gubbi: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/Nakula: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/Navilu: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/Sahadeva: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/Sarai: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/abyssinica: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/arphic: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs /usr/share/fonts/truetype/droid: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/fonts-beng-extra: caching, new cache contents: 6 fonts, 0 dirs /usr/share/fonts/truetype/fonts-deva-extra: caching, new cache contents: 3 fonts, 0 dirs /usr/share/fonts/truetype/fonts-gujr-extra: caching, new cache contents: 5 fonts, 0 dirs /usr/share/fonts/truetype/fonts-guru-extra: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/fonts-kalapi: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/fonts-orya-extra: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/fonts-telu-extra: caching, new cache contents: 2 fonts, 0 dirs /usr/share/fonts/truetype/fonts-yrsa-rasa: caching, new cache contents: 10 fonts, 0 dirs /usr/share/fonts/truetype/freefont: caching, new cache contents: 12 fonts, 0 dirs /usr/share/fonts/truetype/kacst: caching, new cache contents: 15 fonts, 0 dirs /usr/share/fonts/truetype/kacst-one: caching, new cache contents: 2 fonts, 0 dirs /usr/share/fonts/truetype/lao: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/liberation: caching, new cache contents: 16 fonts, 0 dirs /usr/share/fonts/truetype/liberation2: caching, new cache contents: 12 fonts, 0 dirs /usr/share/fonts/truetype/lohit-assamese: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-bengali: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-devanagari: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-gujarati: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-kannada: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-malayalam: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-oriya: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-punjabi: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-tamil: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-tamil-classical: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lohit-telugu: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/lyx: caching, new cache contents: 11 fonts, 0 dirs /usr/share/fonts/truetype/malayalam: caching, new cache contents: 10 fonts, 0 dirs /usr/share/fonts/truetype/nanum: caching, new cache contents: 31 fonts, 0 dirs /usr/share/fonts/truetype/noto: caching, new cache contents: 2 fonts, 0 dirs /usr/share/fonts/truetype/openoffice: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/padauk: caching, new cache contents: 4 fonts, 0 dirs /usr/share/fonts/truetype/pagul: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/samyak: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/samyak-fonts: caching, new cache contents: 3 fonts, 0 dirs /usr/share/fonts/truetype/sinhala: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/tibetan-machine: caching, new cache contents: 1 fonts, 0 dirs /usr/share/fonts/truetype/tlwg: caching, new cache contents: 58 fonts, 0 dirs /usr/share/fonts/truetype/ttf-bitstream-vera: caching, new cache contents: 10 fonts, 0 dirs /usr/share/fonts/truetype/ttf-khmeros-core: caching, new cache contents: 2 fonts, 0 dirs /usr/share/fonts/truetype/ubuntu: caching, new cache contents: 14 fonts, 0 dirs /usr/share/fonts/type1: caching, new cache contents: 0 fonts, 1 dirs /usr/share/fonts/type1/urw-base35: caching, new cache contents: 35 fonts, 0 dirs /root/anaconda3/fonts: skipping, no such directory /root/.local/share/fonts: skipping, no such directory /root/.fonts: skipping, no such directory /usr/share/fonts/X11: skipping, looped directory detected /usr/share/fonts/cMap: skipping, looped directory detected /usr/share/fonts/cmap: skipping, looped directory detected /usr/share/fonts/opentype: skipping, looped directory detected /usr/share/fonts/truetype: skipping, looped directory detected /usr/share/fonts/type1: skipping, looped directory detected /usr/share/fonts/X11/Type1: skipping, looped directory detected /usr/share/fonts/X11/encodings: skipping, looped directory detected /usr/share/fonts/X11/misc: skipping, looped directory detected /usr/share/fonts/X11/util: skipping, looped directory detected /usr/share/fonts/cmap/adobe-cns1: skipping, looped directory detected /usr/share/fonts/cmap/adobe-gb1: skipping, looped directory detected /usr/share/fonts/cmap/adobe-japan1: skipping, looped directory detected /usr/share/fonts/cmap/adobe-japan2: skipping, looped directory detected /usr/share/fonts/cmap/adobe-korea1: skipping, looped directory detected /usr/share/fonts/opentype/malayalam: skipping, looped directory detected /usr/share/fonts/opentype/noto: skipping, looped directory detected /usr/share/fonts/opentype/urw-base35: skipping, looped directory detected /usr/share/fonts/truetype/Gargi: skipping, looped directory detected /usr/share/fonts/truetype/Gubbi: skipping, looped directory detected /usr/share/fonts/truetype/Nakula: skipping, looped directory detected /usr/share/fonts/truetype/Navilu: skipping, looped directory detected /usr/share/fonts/truetype/Sahadeva: skipping, looped directory detected /usr/share/fonts/truetype/Sarai: skipping, looped directory detected /usr/share/fonts/truetype/abyssinica: skipping, looped directory detected /usr/share/fonts/truetype/arphic: skipping, looped directory detected /usr/share/fonts/truetype/dejavu: skipping, looped directory detected /usr/share/fonts/truetype/droid: skipping, looped directory detected /usr/share/fonts/truetype/fonts-beng-extra: skipping, looped directory detected /usr/share/fonts/truetype/fonts-deva-extra: skipping, looped directory detected /usr/share/fonts/truetype/fonts-gujr-extra: skipping, looped directory detected /usr/share/fonts/truetype/fonts-guru-extra: skipping, looped directory detected /usr/share/fonts/truetype/fonts-kalapi: skipping, looped directory detected /usr/share/fonts/truetype/fonts-orya-extra: skipping, looped directory detected /usr/share/fonts/truetype/fonts-telu-extra: skipping, looped directory detected /usr/share/fonts/truetype/fonts-yrsa-rasa: skipping, looped directory detected /usr/share/fonts/truetype/freefont: skipping, looped directory detected /usr/share/fonts/truetype/kacst: skipping, looped directory detected /usr/share/fonts/truetype/kacst-one: skipping, looped directory detected /usr/share/fonts/truetype/lao: skipping, looped directory detected /usr/share/fonts/truetype/liberation: skipping, looped directory detected /usr/share/fonts/truetype/liberation2: skipping, looped directory detected /usr/share/fonts/truetype/lohit-assamese: skipping, looped directory detected /usr/share/fonts/truetype/lohit-bengali: skipping, looped directory detected /usr/share/fonts/truetype/lohit-devanagari: skipping, looped directory detected /usr/share/fonts/truetype/lohit-gujarati: skipping, looped directory detected /usr/share/fonts/truetype/lohit-kannada: skipping, looped directory detected /usr/share/fonts/truetype/lohit-malayalam: skipping, looped directory detected /usr/share/fonts/truetype/lohit-oriya: skipping, looped directory detected /usr/share/fonts/truetype/lohit-punjabi: skipping, looped directory detected /usr/share/fonts/truetype/lohit-tamil: skipping, looped directory detected /usr/share/fonts/truetype/lohit-tamil-classical: skipping, looped directory detected /usr/share/fonts/truetype/lohit-telugu: skipping, looped directory detected /usr/share/fonts/truetype/lyx: skipping, looped directory detected /usr/share/fonts/truetype/malayalam: skipping, looped directory detected /usr/share/fonts/truetype/nanum: skipping, looped directory detected /usr/share/fonts/truetype/noto: skipping, looped directory detected /usr/share/fonts/truetype/openoffice: skipping, looped directory detected /usr/share/fonts/truetype/padauk: skipping, looped directory detected /usr/share/fonts/truetype/pagul: skipping, looped directory detected /usr/share/fonts/truetype/samyak: skipping, looped directory detected /usr/share/fonts/truetype/samyak-fonts: skipping, looped directory detected /usr/share/fonts/truetype/sinhala: skipping, looped directory detected /usr/share/fonts/truetype/tibetan-machine: skipping, looped directory detected /usr/share/fonts/truetype/tlwg: skipping, looped directory detected /usr/share/fonts/truetype/ttf-bitstream-vera: skipping, looped directory detected /usr/share/fonts/truetype/ttf-khmeros-core: skipping, looped directory detected /usr/share/fonts/truetype/ubuntu: skipping, looped directory detected /usr/share/fonts/type1/urw-base35: skipping, looped directory detected /usr/share/fonts/X11/encodings/large: skipping, looped directory detected /root/anaconda3/var/cache/fontconfig: cleaning cache directory /root/.cache/fontconfig: not cleaning non-existent cache directory /root/.fontconfig: not cleaning non-existent cache directory fc-cache: succeeded --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /tmp/ipykernel_1662/385091406.py in <module> ----> 1 get_font_family() /tmp/ipykernel_1662/3296694249.py in get_font_family() 16 17 import matplotlib as mpl ---> 18 mpl.font_manager._rebuild() 19 findfont = mpl.font_manager.fontManager.findfont 20 mpl.font_manager.findfont = findfont AttributeError: module 'matplotlib.font_manager' has no attribute '_rebuild'
-
미해결단 두 장의 문서로 데이터 분석과 시각화 뽀개기
한글폰트 설치 후 나오지 않는 현상 문의
선생님 코드 그대로 저는 윈도우라 그것에 맞게 하는데 옆에 마이너스 부분은 잘 나오는데 위에 제목부분이 여전히 두부모양으로 나와요, 혹시 어느부분이 잘못된건가요?? https://colab.research.google.com/drive/1uil1ftrRI-AOnfygM3urU8_x2-4SIAZY?usp=sharing # matplotlib.pyplot 을 통해 한글폰트를 설정합니다. # plt.style.use 로 "fivethirtyeight" 스타일을 사용해 봅니다. import matplotlib.pyplot as plt plt.rc("font", family="Malgun Gothic") #plt.rc("font", family="AppleGothic") plt.rc("axes", unicode_minus=False) #plt.style.use("fivethirtyeight") pd.Series([1, 3, 5, -7, 9]).plot.bar(title="한글 제목")