논문에 넣을 그림을 그리는데 수식이 이쁘게 표현되지 않아 방법을 찾아보았습니다.
또한, 수식 폰트와 일반 폰트를 혼용해서 쓰는 방법도 찾았습니다.
(1) 첫 번째는 수식 폰트와 일반 폰트를 혼용해서 쓰는 경우입니다.
network라는 글자만 일반 폰트를 사용하려면 \mathrm{network} 이런 식으로 코드를 작성하면 됩니다.
import matplotlib.pyplot as plt
plt.rcParams['axes.unicode_minus'] = False
plt.plot(1)
plt.xlabel('$x_{network}$',size=20)
plt.ylabel('$x_{\mathrm{network}}$',size=20)
(2) 두 번째는 수식 폰트를 바꾸는 방법입니다.
폰트를 바꾸지 않으면 위 그림처럼 x가 수식 표현 같지가 않습니다.
plt.rcParams['mathtext.fontset'] = 'cm' 으로 수식 폰트를 cm으로 바꿔주면 수식 표현과 비슷하게 바뀌는 걸 확인할 수 있습니다.
plt.rcParams['mathtext.fontset'] = 'cm'
plt.plot(1)
plt.xlabel('$x_{network}$',size=20)
plt.ylabel('$x_{\mathrm{network}}$',size=20)
※ 참고문헌
https://matplotlib.org/3.3.0/users/dflt_style_changes.html#math-text
Changes to the default style — Matplotlib 3.3.0 documentation
The default font has changed from "Bitstream Vera Sans" to "DejaVu Sans". DejaVu Sans has additional international and math characters, but otherwise has the same appearance as Bitstream Vera Sans. Latin, Greek, Cyrillic, Armenian, Georgian, Hebrew, and Ar
matplotlib.org
https://stackoverflow.com/questions/43714059/matplotlib-how-to-access-internal-cm-font
matplotlib: how to access internal cm font?
I am using python2.7 on Windows 10, with Anaconda, and having some issue configuring font. First of all, I am aware that this issue is quickly resolved if I install required fonts. But I want to k...
stackoverflow.com
'IT정보 > 코딩' 카테고리의 다른 글
한국데이터정보과학회 초록 Tex 파일 문제 해결 방법 (3) | 2022.04.14 |
---|---|
전이학습, 이걸 왜 지금 알았지? (0) | 2021.04.15 |
[파이썬 증권 데이터 분석] 5장 오류 - Incorrect string value (1) | 2020.12.30 |
jupyter notebook 설정 방법(크롬에서 실행, 시작 폴더 설정) (0) | 2020.12.22 |
pytorch, torchvision, cupy 설치 관련 사이트 및 설치 방법 (0) | 2020.12.22 |