Print vectorized graphic of patches without edges
2 次查看(过去 30 天)
显示 更早的评论
I need to export a vectorized graphic of material data from a finite element simulation. I don't want the lines of the mesh to show, I only want the faces (whose colors correspond to a colormap of material data values). Currently, 'patch' is working well to create exactly the image I need in the MatLab figure. However, I've noticed that when I print to pdf, the image is still pixelated. I am already using the '-painters' renderer. Any tips on how to fix this would be greatly appreciated.
Attached is 'patch_plotter.m' demonstrating my issue, along with a few other things to help narrow down the issue.
In patch_plotter, ax(1,1) shows the image that I'm interested in creating a vectorized version of. Also, ax(1,3) shows that when I allow the edges to be visible, the pdf image indeed does have vectorized angled edges as desired (but like I said, I don't want the edges to be showing, and the edges also result in sloppy spikes sticking out at their endpoints).
Is it possible that the actual faces of the patches are not vectorized graphics while the edges of the patches are vectorized graphics? ( ax(2,3) strongly suggests this conclusion. )
回答(2 个)
J. Alex Lee
2021-8-7
I now believe it is because you are technically plotting 3D patches (telling Matlab there's a z-coordinate, even if they are all zero)
Extract just the x and y coordinates
patch('Faces',dat.t' + 1,'Vertices',dat.p(1:2,:)','FaceVertexCData',dat.d1','FaceColor','flat');
and a quick test looks like pdf export without any tweaks will output vector
8 个评论
Jan
2021-8-9
编辑:Jan
2021-8-9
@Alex Ogren: I have to modify the code a little bit, because tiledlayout is not available in R2018b:
f = figure();
for j = 1:3
ax(j) = subplot(1,3,j);
daspect([1 1 1])
end
...
Then I get a smooth PDF file (open the image in a new tab to see its full size):
The other 2 diagrams look equivalenty.
It is time to send the question to MathWorks support team. The orphaned colored pixels are clearly a bug.
Dave B
2021-8-6
Using exportgraphics might do a little better.
exportgraphics(f,'mypdf2.pdf','ContentType','Vector')
Looks better to me, although better on some of your patches than others. Cool images!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!