Exported 3D plot into SVG shows swirly white lines between chopped subshapes in inkscape

18 views (last 30 days)
when i export the 3D figures into svg using the following line
print(fig2,'LQF_axis','-dsvg','-painters');
svg file is generated and when i open it in Inkscape, there are some swirly white lines separating subshapes. It seems that the vector graphics chopped into pieces in not efficient way and therefore while lines are to be seen.
the problem i have it only with surface,
s=surf(X,Y,LQF_axis','FaceColor','flat','LineStyle','-','EdgeColor','k');hold on;
is there a way to get rid of these annoyed white lines in the exported svg file or to make a better connection of thiny chopped pieces genereted from the print command?
  5 Comments
Felix Maurer
Felix Maurer on 21 Jun 2024
Good day,
there is a workaround for surfaces that works for me in most cases. Since the issue is related to the grid size of the surface, you might plot the surface twice, a second time on top, with (1) different grid resolution, (2) a shift in case you cannot simply change the grid. The idea is that the white spaces of one surface are covered by the other.
Some advice: choose an odd ratio between grid sizes.
It is not a great solution, since you have the entire surface twice, but that is why it is only a workaround.
Here is sample code:
%% first only with one resolution (64)
close all;
figure;
hold on;
for N = 64
x = linspace(0,1,N);
y = linspace(0,1,N);
z = sin(x*(2*pi)).*cos(y'*(3*pi));
surf(x,y,z,'EdgeColor','none')
end
view([225 45])
print(sprintf('testSurfacePre.svg'), '-dsvg','-vector');
hold off
%% now only with two resolutions (64,67)
close all;
figure;
hold on;
for N = [64,67]
x = linspace(0,1,N);
y = linspace(0,1,N);
z = sin(x*(2*pi)).*cos(y'*(3*pi));
surf(x,y,z,'EdgeColor','none')
end
view([225 45])
print(sprintf('testSurfacePostRes.svg'), '-dsvg','-vector');
hold off
%% now only with two resolutions and offset
close all;
figure;
hold on;
k = 0;
for N = [64,67]
x = linspace(0,1,N);
y = linspace(0,1,N);
z = sin(x*(2*pi)).*cos(y'*(3*pi))+k;
k = k+0.001;
surf(x,y,z,'EdgeColor','none')
end
view([225 45])
print(sprintf('testSurfacePostResOffset.svg'), '-dsvg','-vector');
hold off
Abdullah
Abdullah on 21 Jun 2024
Thank your Felix for your comment. i will check it later on and if it worked i will accept your answer

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 3 May 2024
The white lines issue has been around for a while and is an effect of how viewing software rasterizes vectors. There have been some improvements to this issue over the years but these improvements do not solve the issue in all circumstances.
There are many similar threads in this forum that discuss this issue. Here are some similar threads that may or may not provide helpful advice.

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!