필터 지우기
필터 지우기

Filling polygons, not triangles

조회 수: 6 (최근 30일)
esten
esten 2016년 11월 9일
답변: Jan 2016년 11월 15일
When using fill(), MATLAB draws lots of triangles to fill the desired polygon. I have several quite detailed polygons (hundreds and thousands of vertices) which need to be filled. Therefore I would be very pleased if there were a way to make actual polygons, not thousands of triangles when printing to eps or pdf.
Is it possible to do this?

채택된 답변

Jan
Jan 2016년 11월 15일

추가 답변 (1개)

Prannay Jain
Prannay Jain 2016년 11월 15일
I am not quite sure what do you mean by MATLAB draws lots of triangles to fill the desired polygon when using fill(). I am assuming that you are getting triangles or lines in the filled figure when viewed in PDF.
As a matter of fact, this is an issue with the PDF viewer rather than MATLAB.
One solution is to set the “renderer” property to “OpenGL” while exporting or saving the figure.
1) To change the custom renderer to “OpenGL” through “file” menu of the figure: “File” menu of the figure -> “Export Setup” -> Select “Rendering” option from the “Properties” list -> Select “OpenGL Bitmap Format” option from the “Custom Renderer” -> Click on “Apply to Figure” to apply these changes to the current figure -> Click on “OK”.
After this, the saved figure in “PDF” format should not have any white or dotted lines in it. Note that
2) To use the “print” command in your MATLAB to save the current figure to a “PDF” file using “OpenGL” renderer: >> print(gcf,'yourfilename.pdf','-dpdf','-opengl');
Note that you cannot get vector graphics using this approach. An alternative would be to turn off anti-aliasing in the PDF viewer. For example in Adobe Acrobat: From the Adobe Reader > Preferences... menu, select the “Page Display” pane, uncheck “Smooth line art”.
I think there is a similar discussion on this link which may be helpful to you: https://www.mathworks.com/matlabcentral/answers/162257-problem-with-patch-graphics-in-2014b-splits-in-two-along-diagonal
I hope this helps!
  댓글 수: 1
Jan
Jan 2016년 11월 15일
Using the OpenGL renderer let the output be a pixel image instead of a vector image. This has the benefit to avoid display problems in the viewer and drawback, that it cannot be scaled anymore without artifacts.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by