Skip to content

LaTeX rendering is really slow #4880

Closed as not planned
Closed as not planned
@lgeiger

Description

@lgeiger

When usetex=True plotting is a lot slower than the normal.

I generated a simple testplot with some mathtex and timed the rendering time with usetex=True and usetex=False for both saving the plot and just displaying it:

import matplotlib.pyplot as plt
import matplotlib
import numpy as np
%matplotlib inline
x = np.linspace(0, 20, 500)
y = 3 * x + 0.5 * x**3 + 2

def plot(x, y):
    plt.plot(x, y)
    plt.title('simple testplot')
    plt.xlabel('$x$')
    plt.ylabel(r'$3 x + \frac{1}{2} x^3 + 2$')
    plt.savefig('test.pdf')

%timeit -n 1 -r 1 plot(x, y)

Here are the measurements:

  • save pdf usetex=False: 351 ms
  • save pdf usetex=True: 8.34 s
  • display usetex=False: 39 ms
  • display usetex=True: 38.3 ms but it took approx. 7 s until the plot was displayed

My system is running Mac OS X 10.10.4, matplotlib 1.4.3 and the latest LaTeX version.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions