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

MacOSX backend hangs drawing lines with many dashes/dots #6165

Closed
diazona opened this issue Mar 16, 2016 · 3 comments
Closed

MacOSX backend hangs drawing lines with many dashes/dots #6165

diazona opened this issue Mar 16, 2016 · 3 comments
Milestone

Comments

@diazona
Copy link

diazona commented Mar 16, 2016

I've run into a problem drawing plots with dashed or dotted lines that extend out to many times the size of the plot area. This SSCCE demonstrates the issue on my system:

import matplotlib
matplotlib.use('macosx')
import matplotlib.pyplot as plt

line_ymax = 1e6
plot_ymax = 2
plt.plot([0, 0], [1, line_ymax], linestyle='dotted')
plt.ylim(0, plot_ymax)
plt.show()

I instrumented this with a bit of timing code and found that the call to plt.show() takes about 13 seconds on my machine, during which the Python process is using 100% CPU. Playing with the values shows that the time taken by show() seems to be asymptotically linear in line_ymax / plot_ymax. Changing the line style to 'dashed' reduces the time by a factor of 2.5-3, while changing it to 'solid' makes the problem go away entirely. (I suppose this suggests something may be linear in the number of separate line segments being drawn.)

I also ran the code with line tracing enabled (python -m trace -t hang-mwe.py) and identified the specific line that hangs (or at least, the last line to be printed before the trace output pauses):

path.py(260):         return self._simplify_threshold

A larger context from this run is attached in trace.txt, in case it helps; look around line 421.

The problem does not occur in the webagg backend. I also tried swapping in other backends (agg, cairo, pdf, pgf, ps, svg, template - all the options that didn't give an error) for good measure, but none of them displayed anything (though neither did they have any noticeable "hang time").

I found the issue on OS X El Capitan using Matplotlib 1.5.1rc1 and Python 3.4.4, both installed through MacPorts. It goes back at least as far as 1.4.0 (the earliest version I could compile) and is still present in the current master branch (196f344).

@tacaswell tacaswell added this to the unassigned milestone Mar 16, 2016
@tacaswell
Copy link
Member

This is a known issue #5964.

Most of the backends you listed are non-interactive (no gui) so not seeing anything is correct.

Can you use one of the other gui backends (tkagg, qt4agg, etc)?

@diazona
Copy link
Author

diazona commented Mar 17, 2016

OK, sorry, that didn't show up in my searches because I was looking for issues related to line styles, and to rendering of elements that don't appear in the final plot.

I tested on a Linux machine and couldn't reproduce the issue with any of the available interactive backends (GTK3Cairo, WebAgg, Qt4Agg).

I don't have another backend available on the Mac, but I'll see if I can install one.

@efiring
Copy link
Member

efiring commented Mar 21, 2016

This will be fixed by #6178 so I am closing it.

@efiring efiring closed this as completed Mar 21, 2016
@efiring efiring changed the title MacOSX backend hangs drawing lines with many dashes/dots MacOSX backend hangs drawing lines with many dashes/dots Mar 21, 2016
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), unassigned Mar 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants