Exported 3D plot into SVG shows swirly white lines between chopped subshapes in inkscape
16 次查看(过去 30 天)
显示 更早的评论
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1684666/image.png)
5 个评论
Felix Maurer
2024-6-21
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
回答(1 个)
Adam Danz
2024-5-3
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!