FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

OverflowError: In draw_path: Exceeded cell block limit · Issue #5907 · matplotlib/matplotlib · GitHub

Repository navigation

OverflowError: In draw_path: Exceeded cell block limit #5907

Closed

Description

I am using matplotlib 1.5.1 on MacOSX to plot large datasets (roughly 2 million points) in a Jupyter notebook. When generating the plot using...

fig, ax = plt.subplots(1, 1)
panel_data.Gpi2.price.plot(ax=ax, logy=True)

...I get the following error...

<matplotlib.axes._subplots.AxesSubplot at 0x13e9b4860>
Error in callback <function install_repl_displayhook.<locals>.post_execute at 0x10b6cc950> (for post_execute):
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/pyplot.py in post_execute()
    145             def post_execute():
    146                 if matplotlib.is_interactive():
--> 147                     draw_all()
    148 
    149             # IPython >= 2

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/_pylab_helpers.py in draw_all(cls, force)
    148         for f_mgr in cls.get_all_fig_managers():
    149             if force or f_mgr.canvas.figure.stale:
--> 150                 f_mgr.canvas.draw_idle()
    151 
    152 atexit.register(Gcf.destroy_all)

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/backend_bases.py in draw_idle(self, *args, **kwargs)
   2024         if not self._is_idle_drawing:
   2025             with self._idle_draw_cntx():
-> 2026                 self.draw(*args, **kwargs)
   2027 
   2028     def draw_cursor(self, event):

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/backends/backend_agg.py in draw(self)
    472 
    473         try:
--> 474             self.figure.draw(self.renderer)
    475         finally:
    476             RendererAgg.lock.release()

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/figure.py in draw(self, renderer)
   1157         dsu.sort(key=itemgetter(0))
   1158         for zorder, a, func, args in dsu:
-> 1159             func(*args)
   1160 
   1161         renderer.close_group('figure')

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe)
   2322 
   2323         for zorder, a in dsu:
-> 2324             a.draw(renderer)
   2325 
   2326         renderer.close_group('axes')

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/lines.py in draw(self, renderer)
    756                     gc.set_sketch_params(*self.get_sketch_params())
    757 
--> 758                 drawFunc(renderer, gc, tpath, affine.frozen())
    759                 gc.restore()
    760 

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/lines.py in _draw_lines(self, renderer, gc, path, trans)
   1168 
   1169     def _draw_lines(self, renderer, gc, path, trans):
-> 1170         self._lineFunc(renderer, gc, path, trans)
   1171 
   1172     def _draw_steps_pre(self, renderer, gc, path, trans):

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/lines.py in _draw_solid(self, renderer, gc, path, trans)
   1193     def _draw_solid(self, renderer, gc, path, trans):
   1194         gc.set_linestyle('solid')
-> 1195         renderer.draw_path(gc, path, trans)
   1196 
   1197     def _draw_dashed(self, renderer, gc, path, trans):

/Users/drpugh/anaconda/lib/python3.4/site-packages/matplotlib/backends/backend_agg.py in draw_path(self, gc, path, transform, rgbFace)
    164                 self._renderer.draw_path(gc, p, transform, rgbFace)
    165         else:
--> 166             self._renderer.draw_path(gc, path, transform, rgbFace)
    167 
    168     def draw_mathtext(self, gc, x, y, s, prop, angle):

OverflowError: In draw_path: Exceeded cell block limit

...oddly (at least to me) adding a plt.show() statement solved the problem...

fig, ax = plt.subplots(1, 1)
panel_data.Gpi2.price.plot(ax=ax, logy=True)
plt.show()

...yields no error.

Activity

  1. mdboom commented on Jan 25, 2016

    Member

    plt.show() is probably triggering the macosx backend to render the figure, which does not have this limitation. Saving PNG files (and displaying images in %matplotlib inline mode in the Jupyter notebook) uses the agg backend, which does unfortunately have a hard-coded limit on the number of points in a line. You could try breaking your line up into pieces (we don't do this internally because it's difficult to do it in the general case), or consider other ways to reduce your data (seeing 2 million discrete points will be very difficult anyway).

  2. tacaswell commented on Jan 25, 2016

    Member

    I assume that this plot is super jagged? My guess is that there is something funny going on with when path simplification comes in or not. Which backend are you using?

  3. davidrpugh commented on Jan 25, 2016

    Author

    @tacaswell Using the plt.get_backend() command returns...

    'module://ipykernel.pylab.backend_inline'

    ...so inline plotting.

  4. wavexx commented on Feb 2, 2016

    Contributor

    I encountered the same problem today, on linux (python 3, matplotlib 1.5.1~rc1 from debian).

    I'm plotting large time series (101k points). The line plot is dense enough that it ends up looking like a filled area between 2 jagged curves, which is exactly the desired effect, without having to generate the area myself.

    I can show() the plot just fine using the Qt4Agg backend, but cannot savefig().

  5. wavexx commented on Feb 2, 2016

    Contributor

    Or, should I clarify, I can show() it as along as the window size is small enough. I discovered now that I cannot get it big enough to screenshot either...

  6. tacaswell commented on Feb 3, 2016

    Member

    Try setting mpl.rcParams['agg.path.chunksize'] = 10000 or so.

  7. added this to the milestone on Feb 3, 2016
  8. wavexx commented on Feb 4, 2016

    Contributor

    On 03/02/16 05:35, Thomas A Caswell wrote:

    Try setting |mpl.rcParams['agg.path.chunksize'] = 10000| or so.

    That does the trick (both for Qt4Agg and plain Agg).
    Maybe that should go as a commented note in the default matplotlibrc.

  9. anntzer commented on Sep 11, 2017

    Contributor

    This was documented in #8176.

  10. abatoolyn commented on Nov 27, 2018

    Im using
    votes.plot(x='Lat', y='Lon')
    to plot points as a map
    What can I do to overcome the exceeded cell block limit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL