Filling polygons, not triangles

1 visualización (últimos 30 días)
esten
esten el 9 de Nov. de 2016
Respondida: Jan el 15 de Nov. de 2016
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?

Respuesta aceptada

Jan
Jan el 15 de Nov. de 2016

Más respuestas (1)

Prannay Jain
Prannay Jain el 15 de Nov. de 2016
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 comentario
Jan
Jan el 15 de Nov. de 2016
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by