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
Data points beyond axes range plotted when saved to SVG #5925
Data points that lie beyond the axes range are still visible when using savefig to an SVG file. I thought this was solved by #2423, but I'm still getting this as of version 1.5.1.
What are you using to view the SVG? Is it based on librsvg (e.g. most system viewers on Linux)? If so, this was fixed in librsvg 2.40.12. See #4341 for more info.
If you're using a browser or Inkscape, then this is not a known bug and feel free to reopen.
I was struggling with this same problem for a while (and wasn't sure how to check what version of librsvg I had) and think I've found a strange related bug in inkscape: when I open an svg (like test.svg above) normally, it works fine. When I click and drag the file from nautilus (I'm running Ubuntu 16.04) to an already open inkscape window, then I get the same clipping error reported here.
It's a very specific case that most people probably won't encounter and it's easy to avoid it by opening the file in any other way, but I figured I'd report it anyways. Sorry if this is the wrong place for it. (It's really an Inkscape bug, right?)
I have been dealing with this kind of problem for a while. I will take an SVG and bring it into powerpoint and then break it apart so I can edit the individual pieces (I know... I hate powerpoint too, but it's what I need to use for work). However, if I just use xlim or ylim, the data points still exist in the SVG outside the range and are then shown. This means that data is still being saved in the .svg file that should not be there when using xlim and ylim.
I don't think this is a problem with the individual editors, because the data for these extra lines (or dots if using scatter) exist because there is additional data written in the SVG file that should not be there. Yes, certain editors do correctly render these images (for instance if I don't break the SVG apart in powerpoint it looks completely fine) but the fact that additional data is being written to file that shouldn't be means there is an underlying issue here.
I'm not sure if there is something else I am doing wrong, but I think it should be the case that if I call .xlim or .ylim, then the data outside those bounds should not be included in the saved file.
This means that data is still being saved in the .svg file that should not be there when using xlim and ylim.
We don't throw data out - we just limit the view window using the SVG viewBox. We can't throw the data out in case you pan or zoom the image, and while I suppose you could argue that we should remove it when we save, we just don't since SVG (and other vector graphics languages) explicitly support view windows for this purpose, and that is much easier than Matplotlib trying to crop every object that may overspill the axes boundaries.
You can either crop the data yourself before you plot it, or make a new viewBox in Powerpoint (something like Shape Format → Merge Shapes → Intersect.).
Activity
mdboom commentedon Jan 27, 2016
What are you using to view the SVG? Is it based on librsvg (e.g. most system viewers on Linux)? If so, this was fixed in librsvg 2.40.12. See #4341 for more info.
If you're using a browser or Inkscape, then this is not a known bug and feel free to reopen.
sndrtj commentedon Jan 28, 2016
This was indeed rendered by the Gnome image viewer. Firefox renders it correctly. Thanks!
cfbrasz commentedon Apr 7, 2017
I was struggling with this same problem for a while (and wasn't sure how to check what version of librsvg I had) and think I've found a strange related bug in inkscape: when I open an svg (like test.svg above) normally, it works fine. When I click and drag the file from nautilus (I'm running Ubuntu 16.04) to an already open inkscape window, then I get the same clipping error reported here.
It's a very specific case that most people probably won't encounter and it's easy to avoid it by opening the file in any other way, but I figured I'd report it anyways. Sorry if this is the wrong place for it. (It's really an Inkscape bug, right?)
tacaswell commentedon Apr 7, 2017
That should probably be reported to the inkscape folks.
adiMasonD commentedon May 12, 2025
This still appears when viewing the svg in Adobe Illustrator or Edge.
joey-kilgore commentedon Jun 5, 2025
I have been dealing with this kind of problem for a while. I will take an SVG and bring it into powerpoint and then break it apart so I can edit the individual pieces (I know... I hate powerpoint too, but it's what I need to use for work). However, if I just use xlim or ylim, the data points still exist in the SVG outside the range and are then shown. This means that data is still being saved in the .svg file that should not be there when using xlim and ylim.
I don't think this is a problem with the individual editors, because the data for these extra lines (or dots if using scatter) exist because there is additional data written in the SVG file that should not be there. Yes, certain editors do correctly render these images (for instance if I don't break the SVG apart in powerpoint it looks completely fine) but the fact that additional data is being written to file that shouldn't be means there is an underlying issue here.
I'm not sure if there is something else I am doing wrong, but I think it should be the case that if I call .xlim or .ylim, then the data outside those bounds should not be included in the saved file.
jklymak commentedon Jun 5, 2025
We don't throw data out - we just limit the view window using the SVG
viewBox. We can't throw the data out in case you pan or zoom the image, and while I suppose you could argue that we should remove it when we save, we just don't since SVG (and other vector graphics languages) explicitly support view windows for this purpose, and that is much easier than Matplotlib trying to crop every object that may overspill the axes boundaries.You can either crop the data yourself before you plot it, or make a new viewBox in Powerpoint (something like Shape Format → Merge Shapes → Intersect.).
joey-kilgore commentedon Jun 5, 2025
@jklymak Thank you so much for the explanation! Will have to try this idea for some kind of shape intersect in PowerPoint.