2017-05-09 5 views
0

Jupyter의 Matplotlib를 사용하여 음모를 꾸미고 있습니다. 내가 가지고있는 문제는 Mathjax가 기본 Maplotlib 글꼴을 사용하여 수학 글꼴을 렌더링한다는 것입니다 (Dejavu Sans, 저는 믿습니다). Times New Roman을 사용하고 싶기 때문에이 문제는 내 플롯에 두 가지 글꼴이 있습니다. 나는 Jupyter와 Matplotlib에서 가지고있는 문제점을 강조한 짧은 예제를 포함 시켰습니다. (또한 적절한 참조를하기 위해 here의 코드를 사용했고 몇 줄을 추가했습니다).Jupyter의 Mathjax/Matplotlib 글꼴

%matplotlib inline 
import matplotlib.pyplot as plt 
import numpy as np 

t = np.arange(0.0, 2.0, 0.01) 
s = 1 + np.sin(2*np.pi*t) 
plt.plot(t, s) 

plt.rcParams['font.family'] = 'Times New Roman' 

plt.xlabel('See, this is in Times New Roman 12345') 
plt.ylabel(r'$but-this-is-not-12345$') 
plt.title(r'This has both Times New Roman $and-Mathjax$') 
plt.grid(True) 
plt.savefig("test.png") 
plt.show() 

Plot with two fonts

+1

난이 MathJax와는 전혀 무관 틀리지 않는; Matplotlib의 TeX 렌더링 코드입니다. MathJax는 HTML로 수학을 렌더링합니다. 질문을 편집 해 주시겠습니까? 서면으로 오해의 소지가 있습니다. (Jupyter에서 MathJax를 구성하는 방법을 찾고 있습니다.) –

+0

"matplotlib mathtext font를 Times New Roman으로 변경하는 방법"과 Mathjax에 대한 참조를 제거하기위한 몇 가지 작은 수정 사항을 편집 제안했지만 거절되었습니다. . – saintsfan342000

답변

1

당신이 이미 가지고있는 일에 추가로 이러한 설정을 시도해보십시오
plt.rcParams['mathtext.default'] = 'rm'
plt.rcParams['mathtext.fontset'] = 'stix'

관련 문제