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!