4번째 줄: |
4번째 줄: |
| pip install matplotlib | | pip install matplotlib |
| | | |
| + | = 각종 팁 = |
| + | {| class="wikitable" |
| + | !의도 |
| + | !설명 |
| + | !방법 |
| + | |- |
| + | |폰트 추가 |
| + | |기본적으로 한글폰트가 없어 한글이 표시되지 않곤 한다. |
| + | 리눅스의 경우, 설치되어 있는데 반영이 안되는 경우도 있다. |
| + | | |
| + | # <code>fc-list</code>를 통해 폰트의 종류와 경로 파악. |
| + | # <code>python -c "import matplotlib; print(matplotlib.__file__)"</code>를 통해 matplotlib의 경로를 알아낸 후 |
| + | # 사용할 폰트를 복사한다. <code>cp /usr/share/fonts/nanum/Nanum* /.../python3.8/site-packages/matplotlib/mpl-data/fonts/ttf/</code> |
| + | # 적용을 위해 폰트캐시 삭제. <code>rm -rf ~/.cache/matplotlib/*</code> |
| + | |- |
| + | |가용폰트 확인 |
| + | |matplotlib에서 사용 가능한 폰트리스트를 얻는다. |
| + | |<syntaxhighlight lang="python"> |
| + | import matplotlib.font_manager |
| + | font_list = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf') |
| + | [matplotlib.font_manager.FontProperties(fname=font).get_name() for font in font_list] |
| + | </syntaxhighlight> |
| + | |} |
| [[분류:라이브러리]] | | [[분류:라이브러리]] |