Skip to content

y limit with dashed or dotted lines hangs with somewhat big data #1758

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

Closed
fmder opened this issue Feb 18, 2013 · 7 comments
Closed

y limit with dashed or dotted lines hangs with somewhat big data #1758

fmder opened this issue Feb 18, 2013 · 7 comments

Comments

@fmder
Copy link

fmder commented Feb 18, 2013

When plotting uncontinuous lines and rescaling the y axis to centre the view on some part of the data matplotlib hangs in the show() function forcing me to kill the process.

How to reproduce the bug:

import matplotlib.pyplot as plt
import numpy
a = 2**numpy.arange(0, 50)
plt.plot(a, "--")
plt.ylim([0, 100])
plt.show()

This does work perfectly with a continuous line or when the data is smaller and uncontinuous lines.
I use matplotlib 1.2.0 on OSX 10.7.5 and I have Python 2.7.3 installed as a famework (with homebrew).

@pelson
Copy link
Member

pelson commented Feb 18, 2013

Thanks @fmder.

Can you let us know which backend your using?:

import matplotlib
print matplotlib.rcParams['backend']

Cheers,

@fmder
Copy link
Author

fmder commented Feb 18, 2013

>>> print matplotlib.rcParams['backend']
MacOSX

@tacaswell
Copy link
Member

@fmder Is this still a problem on newer version of mpl? (I don't have a mac set up to test this)

@mdboom
Copy link
Member

mdboom commented Jan 21, 2014

I can still reproduce this with today's master. I suspect this is due to some strange limitation of the Quartz rendering library.

@mdehoon: Any thoughts?

@cimarronm
Copy link
Contributor

I've seen this before with Quartz. I believe the problem is that when CGContextSetLineDash is set the underlying stroke creates many individual lines in the rendering. So, on a very long line, Quartz takes forever to draw the enormous amount of lines created from the dash pattern.

In this case with the exponential data set and the limits set as so, the lines in terms of pixels are insanely big and I bet the time for Quartz to finish would be something completely absurd.

@mdehoon
Copy link
Contributor

mdehoon commented Feb 3, 2014

It's indeed CGContextStrokePath that is taking forever to finish.
The arguments that renderer.draw_path receives are:

path = Path([[ 0.00000000e+00 1.00000000e+00]
[ 1.00000000e+00 2.00000000e+00]
[ 2.00000000e+00 4.00000000e+00]
[ 3.00000000e+00 8.00000000e+00]
[ 4.00000000e+00 1.60000000e+01]
...
[ 4.60000000e+01 7.03687442e+13]
[ 4.70000000e+01 1.40737488e+14]
[ 4.80000000e+01 2.81474977e+14]
[ 4.90000000e+01 5.62949953e+14]], None)

transform = Affine2D(array([[ 9.92, 0. , 80. ],
[ 0. , 3.84, 48. ],
[ 0. , 0. , 1. ]]))

This suggests that we are trying to draw the full line instead of just the section that will be visible in the window. Perhaps the calling function (_ draw_dashed in matplotlib/lines.py, called as part of the draw method of Line2D) should only draw the section of the line that will be visible, rather than the whole thing? Currently it seems to rely on clipping in order to show the visible section only.

@tacaswell tacaswell added the OSX label Mar 3, 2014
@tacaswell tacaswell added this to the v1.5.x milestone Aug 17, 2014
@efiring
Copy link
Member

efiring commented May 22, 2016

Closed by #6178.

@efiring efiring closed this as completed May 22, 2016
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.1 (next point release) May 22, 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

8 participants