Crash with text.usetex=True and plt.annotate #1583

Merged
merged 3 commits into from Dec 17, 2012

Projects

None yet

3 participants

@jakevdp
Contributor
jakevdp commented Dec 10, 2012

The following minimal example causes a crash on the current master:

import matplotlib
import matplotlib.pyplot as plt

matplotlib.rcParams['text.usetex'] = True
plt.annotate(" ", (0, 0), (1, 0), arrowprops=dict(arrowstyle='->'))

plt.show()

If " " is changed to "" (an empty string) or if the arrowprops argument is removed, then the crash doesn't happen. Here is the traceback:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
    return self.func(*args)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 276, in resize
    self.show()
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 348, in draw
    FigureCanvasAgg.draw(self)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 439, in draw
    self.figure.draw(self.renderer)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/figure.py", line 999, in draw
    func(*args)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/axes.py", line 2093, in draw
    a.draw(renderer)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/text.py", line 2031, in draw
    self.arrow_patch.draw(renderer)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/patches.py", line 4001, in draw
    path, fillable = self.get_path_in_displaycoord()
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/patches.py", line 3949, in get_path_in_displaycoord
    shrinkB=self.shrinkB * dpi_cor
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/patches.py", line 2507, in __call__
    clipped_path = self._clip(path, patchA, patchB)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/patches.py", line 2452, in _clip
    left, right = split_path_inout(path, insideA)
  File "/home/vanderplas/PythonEnv/pydev/local/lib/python2.7/site-packages/matplotlib/bezier.py", line 242, in split_path_inout
    ctl_points, command = next(path_iter)
StopIteration

I'm running ubuntu with python 2.7.3, and the following:

>>> matplotlib.__version__
'1.3.x'
>>> matplotlib.rcParams['backend']
'TkAgg'

I've seen the crash also using Agg.

@ivanov
Member
ivanov commented Dec 14, 2012

@mdboom's change fixes Jake's example for me, but still breaks if I use two spaces instead of just one.

 plt.annotate("  ", (0, 0), (1, 0), arrowprops=dict(arrowstyle='->'))

I added a commit to deal with those, will submit PR against Mike's branch with that

@mdboom mdboom Merge pull request #12 from ivanov/annotate_space
more complete fix for #1583 (multiple spaces)
7e91d71
@mdboom mdboom merged commit 422712d into matplotlib:v1.2.x Dec 17, 2012
@pelson pelson added a commit to pelson/matplotlib that referenced this pull request Jan 9, 2014
@pelson pelson Added a test for #1583 and fixed the underlying problem. ddf57b1
@pelson pelson added a commit to pelson/matplotlib that referenced this pull request Jan 9, 2014
@pelson pelson Added a test for #1583 and fixed the underlying problem. 3a8eabb
@pelson pelson added a commit to pelson/matplotlib that referenced this pull request Jan 9, 2014
@pelson pelson Added case from #1583. cacf3ef
@pelson pelson added a commit to pelson/matplotlib that referenced this pull request Jan 14, 2014
@pelson pelson Added a test for #1583 and fixed the underlying problem. 19c8ec4
@pelson pelson added a commit to pelson/matplotlib that referenced this pull request Jan 14, 2014
@pelson pelson Added a test for #1583 and fixed the underlying problem. 368f82a
@mdboom mdboom deleted the mdboom:annotate_space branch Aug 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment