How to print figure to an .eps file properly?

I'm printing the same figures as .png and .eps files. The .png looks fine, but the .eps appear to have some issues:
  • Somehow the image is cut to minimal space, but it also appear to cut the last number in my X axis.
  • My Y axis is set to a log scale, and so the 10^x (x=0,1,2,...) numbers don't look good at all (they look fine in the .png file).
  • In the legend of one of my figures there is an equation using sprintf(...). The text there doesn't scale properly with the box of the legend - it goes beyond the box untill it is cut in the bounds of the image.
I'm using the commands:
...
print(figure_current,'-dpng','-r200',file_figure_png_full_location);
...
print(figure_current,'-depsc','-painters',file_figure_eps_full_location);

 채택된 답변

the cyclist
the cyclist 2019년 8월 19일

0 개 추천

Try using '-opengl' rather than '-painters' for the renderer.

댓글 수: 5

tensorisation
tensorisation 2019년 8월 28일
편집: tensorisation 2019년 8월 28일
Been away for abit. I tried this today and strangely it worked. When I looked up this issue I actually saw people recommending to use '-painters' for .eps, so I didn't think of using something else. Any idea why does '-painters' not work properly, and '-opengl' does?
the cyclist
the cyclist 2019년 8월 28일
I can't give you a satisfying answer to "why?". My suggestion was based on seeing this statement in the Vector Graphics File section of the documentation for print:
"The default figure renderer is OpenGL. If the figure renderer differs from the renderer used when generating output, some details of the saved figure can differ from the figure on the display. If necessary, you can make the displayed figure and the saved figure use the same renderer. Set the Renderer property for the figure or specify the renderer input argument to the print function."
And I had noticed that you had changed the renderer for the eps file, so that seemed a likely culprit.
When I first tried this, I didn't put a renderer at all, and it gave me the same results I had with '-painters'. Doesn't this mean that '-painters' is default for print?
Rik
Rik 2019년 8월 28일
If I recall correctly, print selects the renderer based on the image format (pixel or vector). That should be mentioned in the doc.
the cyclist
the cyclist 2019년 8월 28일
I don't recall for sure, and I'm currently on a machine that doesn't have MATLAB installed (horrors!) so I can't check. But I think the default renderer might be something like "Auto", meaning that the MATLAB will choose which one to use based on properties of the figure. I poked around the documentation a bit, but could not find a definitive answer.

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

추가 답변 (1개)

the cyclist
the cyclist 2019년 8월 17일

0 개 추천

Try using export_fig.

댓글 수: 1

tensorisation
tensorisation 2019년 8월 18일
편집: tensorisation 2019년 8월 18일
Before resorting to trying to use this external elaborate shared library tool, isn't there a way to just properly save a figure as an .eps file in Matlab?

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

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2019년 8월 17일

댓글:

2019년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by