EunGyeongKim

[paper] Matplotlib으로 논문용 figure그리기 본문

Language/Python

[paper] Matplotlib으로 논문용 figure그리기

EunGyeongKim 2022. 8. 10. 15:32

 

관련 링크

 

SciencePlots

Format Matplotlib for scientific plotting

pypi.org

 

1. latex 깔아주기

!sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super

 

2. font 깔아주기

# Ubuntu / Debian
sudo apt update
sudo apt install fonts-noto-cjk

# macOS
brew tap homebrew/cask-fonts
brew cask install font-noto-serif-cjk-tc
brew cask install font-noto-serif-cjk-sc
brew cask install font-noto-serif-cjk-jp
brew cask install font-noto-serif-cjk-kr

# archlinux
sudo pacman -S noto-fonts-cjk

 

3. font 깔고 rebuild 하기

import matplotlib.font_manager as fm
fm._rebuild()

 

4. matplotlib 위치 확인 

import matplotlib
print(matplotlib.get_configdir())

-> /root/.config/matplotlib

 

5. matplotlib시 default가 아닌 다른폰트 설정

import matplotlib.pyplot as plt 
plt.style.use('science')
plt.rcParams.update({
    "font.family": "serif",   # specify font family here
    "font.serif": ["Times"],  # specify font here
    "font.size":11})          # specify font size here

 

6. Scienceplots  깔기

!pip install SciencePlots
import matplotlib.pyplot as plt
plt.style.reload_library()
plt.style.use('science')

 

7. 사용!!!! style 지정해서 사용하기

import matplotlib.pyplot as plt

plt.style.use('science')

 

예시 : style.use(science)

style.use(science, ieee)

 

이 이외에도 여러 템플릿이 있다! 

템플릿 확인은 링크 에서 확인!! 

이제 논문 형식에 맞는것을 찾아 적용하면 끝!!1

figure 못그린다고 이제 야단 안맞아도 되겠다 ㅎㅎㅎㅎ

Comments