Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Dec 17, 2012

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Dec 11, 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
Copy link
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

more complete fix for matplotlib#1583 (multiple spaces)
mdboom added a commit that referenced this pull request Dec 17, 2012
Crash with text.usetex=True and plt.annotate
@mdboom mdboom merged commit 422712d into matplotlib:v1.2.x Dec 17, 2012
pelson added a commit to pelson/matplotlib that referenced this pull request Jan 9, 2014
pelson added a commit to pelson/matplotlib that referenced this pull request Jan 9, 2014
pelson added a commit to pelson/matplotlib that referenced this pull request Jan 9, 2014
pelson added a commit to pelson/matplotlib that referenced this pull request Jan 14, 2014
pelson added a commit to pelson/matplotlib that referenced this pull request Jan 14, 2014
@mdboom mdboom deleted the annotate_space branch August 7, 2014 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants