We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

pylab_examples example code: tex_demo.py

Next topic

pylab_examples example code: text_handles.py

This Page

pylab_examples example code: tex_unicode_demo.pyΒΆ

(Source code, png, hires.png, pdf)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
This demo is tex_demo.py modified to have unicode. See that file for
more information.

from __future__ import unicode_literals
import numpy as np
import matplotlib
matplotlib.rcParams['text.usetex'] = True
matplotlib.rcParams['text.latex.unicode'] = True
import matplotlib.pyplot as plt

plt.figure(1, figsize=(6, 4))
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(2*2*np.pi*t) + 2
plt.plot(t, s)

plt.xlabel(r'\textbf{time (s)}')
plt.ylabel(r'\textit{Velocity (\u00B0/sec)}', fontsize=16)
plt.title(r"\TeX\ is Number \
          fontsize=16, color='r')

Keywords: python, matplotlib, pylab, example, codex (see Search examples)