Last active
December 16, 2015 21:58
-
-
Save phobson/5503195 to your computer and use it in GitHub Desktop.
can't get the math/tick labels right.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if 1: | |
from matplotlib import rc, font_manager | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# set up the fonts | |
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']}) | |
rc('text', usetex=True) | |
rc('mathtext', fontset='stixsans') | |
#ticks_font = font_manager.FontProperties(family='Helvetica', style='normal', | |
# weight='normal', stretch='normal') | |
#fontProperties = {'family':'sans-serif','sans-serif':['Helvetica'], | |
# 'weight' : 'normal', 'size' : 10} | |
fig, ax = plt.subplots() | |
t = np.arange(0.0, 1.0+0.01, 0.01) | |
s = np.cos(2*2*np.pi*t)+2 | |
ax.plot(t, s) | |
ax.set_xlabel(r'\textbf{time (s)}') | |
ax.set_ylabel(r'\textit{voltage (mV)}',fontsize=16) | |
ax.set_title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!", | |
fontsize=16, color='r') | |
ax.text(0.4, 1.05, 'Numbers are 123456') | |
ax.xaxis.grid(True) | |
ax.yaxis.grid(True) | |
#ax.set_xticklabels(ax.get_xticks(), fontProperties) | |
#ax.set_yticklabels(ax.get_yticks(), fontProperties) | |
fig.savefig('tex_demo.png', dpi=300) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sdfgsdfg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment