Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Huge off-screen filled polygons cause agg rasterizer to fail #3909

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
Vayu opened this issue Dec 11, 2014 · 7 comments
Closed

Huge off-screen filled polygons cause agg rasterizer to fail #3909

Vayu opened this issue Dec 11, 2014 · 7 comments

Comments

@Vayu
Copy link

Vayu commented Dec 11, 2014

Polygons are always fully rasterized before being clipped to viewport size. It causes rasterizer to fail in presence of huge polygons which extend outside current plotting limits.

matplotlib.pyplot.fill_between is a command that can produce such polygons inadvertently (zooming a plot with fill_between can also produce this error).

A simple example

import numpy as np
import matplotlib.pyplot as plt
plt.switch_backend('qt4agg')
yup = np.array([6e6, -0.1, 0.8])
ydown = np.array([2e6, -1.8, 0.5])
x = np.linspace(0, 2, 3)
axs = plt.subplot(111)
axs.fill_between(x, ydown, yup)
axs.set_xlim(1, 2)  # comment this to see full plot
axs.set_ylim(-2, 3)  # comment this to see full plot
plt.show()

Crashes (trace from 1.4.2 but problem is present in master as well)

Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 338, in resizeEvent
    self.draw()
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 148, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 469, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1079, in draw
    func(*args)
  File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 2092, in draw
    a.draw(renderer)
  File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/collections.py", line 751, in draw
    Collection.draw(self, renderer)
  File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/collections.py", line 293, in draw
    mpath.Path(offsets), transOffset, tuple(facecolors[0]))
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 124, in draw_markers
    return self._renderer.draw_markers(*kl, **kw)
OverflowError: Allocated too many blocks

While the desired result would be
figure_1

@mdboom
Copy link
Member

mdboom commented Dec 11, 2014

Yes -- we have a clipper that works for non-filled paths, but it gets turned off for filled ones. We need to implement a clipper that supports filled paths. Any takers?

@pelson
Copy link
Member

pelson commented Dec 11, 2014

We need to implement a clipper that supports filled paths. Any takers?

Really? I didn't know that. Second time in a week that Clipper (http://www.angusj.com/delphi/clipper.php) has come up...

Definitely an interesting problem.

@tacaswell
Copy link
Member

There are also some outstanding clipping issues with filled polygons in the pgf backend #2885 #3693

@tacaswell tacaswell added this to the 1.5.0 milestone Feb 7, 2015
@tacaswell tacaswell modified the milestones: next point release, proposed next point release Jul 16, 2015
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@QuLogic
Copy link
Member

QuLogic commented Mar 26, 2018

I was going to try out clipper, but if I'm not mistaken, the example given works on master (and maybe even 2.1.2)?

@anntzer
Copy link
Contributor

anntzer commented Mar 26, 2018

Perhaps #9488 would be of interest for you (haven't looked at that recently though).

@github-actions
Copy link

github-actions bot commented Mar 8, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Mar 8, 2023
@jklymak
Copy link
Member

jklymak commented Mar 8, 2023

My testing wasn't exhaustive, but this works fine on modern Matplotlib. If there are any followups, please open a new big report.

@jklymak jklymak closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2023
@QuLogic QuLogic removed the status: inactive Marked by the “Stale” Github Action label Mar 16, 2023
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

7 participants