What is your favorite way to export figure for use in LaTeX?

조회 수: 264 (최근 30일)
Craig
Craig 2011년 10월 13일
편집: Maalek Naghavi 2021년 6월 12일
Matlab's standard plotting tools are sufficient for visualizing intermediate results, but there are many reasons why you can't simply export a eps or pdf to be included in a LaTeX generated report or publication. I've tried a several options varying from explicitly setting the fonts to using export tools such as matlab2tikz; but what tools/ methods do you find the most effective at easily making a beautiful figure without extensive effort?
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 10월 13일
Most effective? Hand it over to a grad student or PDF (Post-Doctoral Fellow) ;-)
Craig
Craig 2011년 10월 14일
That sounds like a great idea, can I borrow one of yours?

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

답변 (4개)

ibrahim thamary
ibrahim thamary 2018년 2월 19일
I found this useful:
https://dgleich.github.io/hq-matlab-figs/
width = 3; % Width in inches
height = 3; % Height in inches
set(gcf,'InvertHardcopy','on');
set(gcf,'PaperUnits', 'inches');
papersize = get(gcf, 'PaperSize');
left = (papersize(1)- width)/2;
bottom = (papersize(2)- height)/2;
myfiguresize = [left, bottom, width, height];
set(gcf,'PaperPosition', myfiguresize);
% Save the file as PNG
print('r9','-dpng','-r300');
print('r9','-depsc2','-r300');

Oliver Woodford
Oliver Woodford 2011년 10월 13일
I create the graph or image in a MATLAB figure on screen exactly as I want it to appear in the paper. Then I save the figure as either a PDF or a PNG using export_fig. Finally I insert the output in latex using includegraphic and compile using pdflatex.
Export_fig respects figure dimensions, crops whitespace, embeds fonts and saves bitmaps at high quality, so the results look good.
  댓글 수: 1
Image Analyst
Image Analyst 2011년 10월 13일
Oliver's export_fig, mentioned in the FAQ, is certainly a very popular, if not the most popular, way to do it. http://matlab.wikia.com/wiki/FAQ#How_do_I_save_my_figure.2C_axes.2C_or_image.3F_I.27m_having_trouble_with_the_built_in_MATLAB_functions.

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


Daniel Shub
Daniel Shub 2011년 10월 14일
While beauty is subjective, I don't think that it is possible to produce a beautiful figure without extensive effort. Even with extensive effort, I do not think that MATLAB can produce a beautiful figure. Now quick, publishable and clear, then you want to use export_fig.

Maalek Naghavi
Maalek Naghavi 2021년 6월 12일
편집: Maalek Naghavi 2021년 6월 12일
Matlab-generated PDF graph
If you have saved your Matlab-created graph as a pdf file, then you can use it in your Latex document using:
\includegraphics[width=\textwidth,height=\textheight,scale=1]{path/to/figure.pdf}
You may change the size of your figure by tuning the options inside the braces to fit it to your space. Then compile your whole document:
pdflatex -interaction=nonstopmode -src main.tex
Matlab-generated EPS graph
If you have saved your Matlab-created graph as an eps file, then the same procedure applies for including the figure. For compilation use:
latex -interaction=nonstopmode -src main.pdf
dvips main.dvi
ps2pdf main.ps
If you are creating a presentation using beamer class, see beamer's documentation, chapter Creating PostScripts.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by