Skip to content

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

Closed

Description

@fmder

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).

Activity

  1. pelson commented on Feb 18, 2013

    @pelson
    Member

    Thanks @fmder.

    Can you let us know which backend your using?:

    import matplotlib
    print matplotlib.rcParams['backend']
    

    Cheers,

  2. fmder commented on Feb 18, 2013

    @fmder
    Author
    >>> print matplotlib.rcParams['backend']
    MacOSX
  3. tacaswell commented on Jan 20, 2014

    @tacaswell
    Member

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

  4. mdboom commented on Jan 21, 2014

    @mdboom
    Member

    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?

  5. cimarronm commented on Feb 2, 2014

    @cimarronm
    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.

  6. mdehoon commented on Feb 3, 2014

    @mdehoon
    Contributor

    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.

  7. added this to the milestone on Aug 17, 2014
  8. efiring commented on May 22, 2016

    @efiring
    Member

    Closed by #6178.

  9. modified the milestones: , on May 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions