You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Off-axes scatter() points unnecessarily saved to PDF when coloured #2488
Scatter plotting a bunch of points while specifying the colour of each point, then changing the axes limits so none of the points are visible, and then saving the result to a PDF, results in a file just as big as if the points were all visible within their default axes limits. This doesn't seem to happen if the colour arg isn't passed to scatter(). I haven't tried, but specifying other kinds of point specific attributes, like size, might also trigger the problem . Also, I haven't tried any of the other vector backends, but they may be affected as well.
I was under the impression from @mdboom that scatter() had a very different code path, and fixing this for scatter would be much more difficult than for plot():
Yes -- scatter is so much more flexible -- each item can have its own transform, and the only way to determine (in the general case) if a patch is off the axes is to actually transform all of its points anyway, which probably doesn't result in terribly large savings (though I suppose one save the stroking time). If you pre-determine that all of the transformations scale/translation without rotation/skew, one could simply transform the bounding box of the patch to determine whether it's outside of the image, and this would probably be fast enough to be worth the effort.
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!
@henry4ni anyone is welcome to work on anything but please note that "Good First Issue” means this is suitable for someone new to Matplotlib, but not necessarily new to coding/python in general. "Medium difficulty" means it is not suitable for very inexperienced developers.
Activity
tacaswell commentedon Jan 17, 2014
Closed as I believe that #2423 fixed this problem.
mspacek commentedon Jan 18, 2014
I was under the impression from @mdboom that scatter() had a very different code path, and fixing this for scatter would be much more difficult than for plot():
#2423 (comment)
Has scatter been tested? I should pull from git to test it out again, but I'm not quite feeling up for that right now...
tacaswell commentedon Jan 20, 2014
@mspacek Yeah, you are right, closed this erroneously.
mdboom commentedon Jan 21, 2014
Yes -- scatter is so much more flexible -- each item can have its own transform, and the only way to determine (in the general case) if a patch is off the axes is to actually transform all of its points anyway, which probably doesn't result in terribly large savings (though I suppose one save the stroking time). If you pre-determine that all of the transformations scale/translation without rotation/skew, one could simply transform the bounding box of the patch to determine whether it's outside of the image, and this would probably be fast enough to be worth the effort.
petehuang commentedon Jan 7, 2017
Sharing my results on 1.5.3 using TkAgg:
github-actions commentedon Mar 3, 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!
mspacek commentedon May 2, 2023
This issue remains in matplotlib 3.7.1, Python 3.8, Qt5QAgg backend:
11 remaining items
henry4ni commentedon Nov 1, 2025
Hello! Is this issue still unresolved?
I’m interested in contributing to this issue as my first open-source contribution.
rcomer commentedon Nov 1, 2025
@henry4ni anyone is welcome to work on anything but please note that "Good First Issue” means this is suitable for someone new to Matplotlib, but not necessarily new to coding/python in general. "Medium difficulty" means it is not suitable for very inexperienced developers.
backend/pdf: Skip off-axis markers in draw_path_collection
backend/pdf: Skip off-axis markers in draw_path_collection
Fix PDF bloat for off-axis scatter with per-point colors
Fix PDF bloat for off-axis scatter with per-point colors
Fix PDF bloat for off-axis scatter with per-point colors
Fix PDF bloat for off-axis scatter with per-point colors
Fix PDF bloat for off-axis scatter with per-point colors
Human gold patch for matplotlib__matplotlib-30746