How to Output Accurate PDF from Matlab figure
Mostrar comentarios más antiguos
Hi everyone:
For some reason, I need to plot the mask of a microfluid device in Matlab, which consists of many posts separated by certain distance The plotting process is easy but when I tried to 'print' it into PDF file, the image was distorted (circles are not round, and they have obvious defect on them), and the spacing was not right(shortened).
I've tried function 'rectangle', code like:
function drawFilledCircle (center_x, center_y, radius)
%%Draw a filled circle
xc = center_x; yc = center_y;
r = radius;
x = r*sin(-pi:0.01*pi:pi) + xc;
y = r*cos(-pi:0.01*pi:pi) + yc;
fill(x, y, [0,0,0]);
and even a function called 'filledCircle' which I found on fileexchange.
But I always got the wrong thing. I don't know what I can do to fix it.
Please help.
P.S. I attached the original matlab figure and the printed PDF for references.
P.S.2 I've also tried to output them into other formats like EPS, but even EPS doesn't look right.
4 comentarios
lvn
el 18 de Mzo. de 2014
I tried zooming in on a small part of your figure (it seems to consist of hexagons made up from circles) and exporting it to pdf.
print -dpdf test1.pdf
I attach the result which looks to be ok.
Frank
el 18 de Mzo. de 2014
lvn
el 19 de Mzo. de 2014
Could you post the complete code that would reproduce test.fig? I would like to see if I manage to export it correctly.
Frank
el 19 de Mzo. de 2014
Respuesta aceptada
Más respuestas (4)
Chad Greene
el 18 de Mzo. de 2014
0 votos
I highly recommend switching to export_fig instead of using print. Here's export_fig: http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig
Oliver Woodford, the author of export_fig has a quite helpful and succinct site with plenty of picture examples and troubleshooting tips here: https://sites.google.com/site/oliverwoodford/software/export_fig
Does the attached pdf look correct?
4 comentarios
Frank
el 18 de Mzo. de 2014
Chad Greene
el 18 de Mzo. de 2014
I'm still not exactly sure what the problem is; perhaps it's an issue with your pdf renderer? Does this png look correct?
Frank
el 18 de Mzo. de 2014
Frank
el 18 de Mzo. de 2014
Chad Greene
el 18 de Mzo. de 2014
0 votos
Oh, interesting. I see the problem now, but is this a pdf issue, or an issue with the filled circle function? Perhaps simply creating a scatter plot and setting the size of the markers would fix it? http://www.mathworks.com/matlabcentral/answers/101738
Chad Greene
el 19 de Mzo. de 2014
0 votos
Frank,
Follow the circles command with axis equal to ensure the circles don't get squashed.
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!