Filling polygons, not triangles

4 次查看(过去 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