Lines appearing on svg images from export_fig

HI,
I'm using export_fig to export svg imgas that goes into ms word. However, a grid of non-colored lines appears on the images which becomes very apparent on surface plots and it looks like garbage. Particularly frustrating when there is an intended grid as well. The grid changes with the resolution. Is there a was to get rid of this?

8 Comments

DGM
DGM on 30 Oct 2021
Edited: DGM on 30 Oct 2021
Are you using fig2svg with export_fig? If you aren't, export_fig falls back to using the built-in svg conversions which will render certain figure components as tiled raster objects (hence the seams). I believe export_fig will also dump warning messages about this when it does.
I haven't had stellar experience with fig2svg on complex figures, but it's worth a try.
How do I enforce fig2svg with export_fig? I have not used it by choice, no. Haven't seen any error messages
I also realised I'm running v2017b, I'll install 2020 and try that. I read there were some particular problems prior to v2018
edit: Found out how to proceed with fig2svg. Also found out that export_fig was set to "-silent" and indeed, it throws a warning regarding not using fig2svg!
IIRC, it just checks to see if the third-party tools are available and uses them automatically.
From export_fig() docs:
% SVG output uses Matlab's built-in SVG export if available, or otherwise the
% fig2svg (https://github.com/kupiqu/fig2svg) or plot2svg
% (https://github.com/jschwizer99/plot2svg) utilities, if available.
Whether it dumps a message might depend on what version of export_fig() you downloaded. Yair has been updating it rairly regularly.
Export_fig() uses 'painters' renderer for vector output, but I don't know if an explicit specification of a different renderer would change anything.
EDIT:
I just found this:
Lines in patch objects - when exporting patch objects to PDF using the painters renderer (default), sometimes the output can appear to have lines across the middle of rectangular patches; these lines are the colour of the background, as if there is a crack in the patch, allowing you to see through. This appears to be due to bugs in MATLAB's internal vector rendering code. These lines can often be removed from the PDF using software such as InkScape. Sometimes disabling anti-aliasing in the PDF-reader software can get rid of the lines (discussion).
Tried fig2svg, can't really say it was any success... Judging from the comments regarding the function it seems that many are displeased with it, as I am.
Upgrading export_fig and matlab didn't help either, same problem still remains.
It seems export_fig didn't recognise plot2svg either, even if it's installed and on the path. May try to print directly from plot2svg.
Will see if I can sort the problem by postprocessing or similar. Other suggestions are very welcome
Tried plot2svg, produced the same garbage as fig2svg. Seems that eps is the only vector format that produces a decent result, except that the grid is screwed up. And it has to be converted to svg
Did you try exportgraphics()?
Yes, tried exportgraphics (of which .eps is the only viable vector outcome), similar result as export_fig, messed up grid, but also undesirable cropping of the image.
It seems export_fig alters linewidths and markersizes when exporting to eps, because the appearance change a lot compared to svg of tif. Axes, markers, all changes. Perhaps because the format doesn't allow certain linewidth?
Edit: So I assume that the grid issue I keep having with eps is that transparency is not supported, and therefore it is rendered as dashes instead. Seems that the linewidths issue can be sorted by simply adjust it a bit, 0.5->0.4 gives similar result visually as when saving as svg/ tif.
Gave up on the idea of saving directly to svg. Went for eps instead, which renders ok after some tweaking on linewidths here and there, converting the eps to svg using cloudconvert which works really well and maintains the quality. Had to give up on the grid, the grid doesnt work with contourf and eps, it becomes plotted on top of the surface as dashed lines when exporting to eps. All other plots, lines, bars etc, works with grid however.

Sign in to comment.

Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products

Asked:

on 29 Oct 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!