matlab作圖 latex插圖


推薦用saveas eps,再用eps2pdf轉成pdf。這樣可以之間pdflatex編譯。 

if result.savepic
saveas(gcf,[ pwd '/picture/right_' num2str(problem.numsamples) '_' num2str(problem.Ttest) problem.name '.fig']);
saveas(gcf,[ pwd '/picture/right_' num2str(problem.numsamples) '_' num2str(problem.Ttest) problem.name '.eps'],'epsc'); %帶彩色
eps2pdf([pwd '/picture/right_' num2str(problem.numsamples) '_' num2str(problem.Ttest) problem.name '.eps']);
end

 

%template
result.linspec = {'r.-','b*-','go-','rs-','b^-','gd-'}; load pgsd figure for j=2:5 tmp1=[]; index=[]; for i=1:length(a(1,:)) if a(j,i)~=0 tmp1=[tmp1 a(j,i)]; index=[index a(1,i)]; end end plot(index,tmp1,result.linspec{j});hold on; end grid on legend('SGD','SGD+AdaGrad','pSGD+AdaGrad','pSGD','Location','SouthEast') xlabel('Training Time (min) ') ylabel('Accuracy (%) ') figure_FontSize=20; set(get(gca,'XLabel'),'FontSize',figure_FontSize,'Vertical','top'); set(get(gca,'YLabel'),'FontSize',figure_FontSize,'Vertical','middle'); set(findobj('FontSize',10),'FontSize',figure_FontSize); set(findobj(get(gca,'Children'),'LineWidth',0.5),'LineWidth',2.3); %set(findobj(get(gca,'Children'),'MakerSize',1),'MakerSize',5); set(gca,'FontSize',figure_FontSize) saveas(gcf,[ pwd '/map5_boldfi' '.fig']); saveas(gcf,[ pwd '/map5_boldfi' '.eps'],'epsc'); eps2pdf( [pwd '/map5_boldfi' '.eps']); % Place second set of axes on same plot % % handaxes2 = axes('position', [0.2 0.5 0.4 0.3]); % % set(handaxes2, 'box', 'off'); % % semilogx(cumsum(parametertmp),cputimetmp./gputimetmp); % % Adjust XY label font % xlabel('Parameter number'); % ylabel('Speed gain ratio'); % grid on % set(get(handaxes2, 'xlabel'), 'fontname', 'times') % set(get(handaxes2, 'ylabel'), 'fontname', 'times') % %title('Comparision of LSTM Efficiency with CPU and GPU ')

 

多個插圖並排,互不相關。

 
 
 
         \usepackage{floatrow}
 
 
 
         
 
 
 
         \begin{figure}
\begin{floatrow}[2]
\ffigbox{ \caption{Various Sigmoid functions and their derivatives} \label{sigmoidfunction} }{\includegraphics[width=6.5cm]{picture//sigmoid} }
\ffigbox{ \caption{Experiments with different sigmoid functions (lbfgs)}
\label{newexcitation}}{\includegraphics[width=6.5cm]{picture//newexcitation} }
\end{floatrow}
\end{figure}
 
 
 
         


相關,用subfloat[caption]{\includegr... \quad(換行)


For Pdftex the best vector format ist PDF. Many programs can output PDF. Inkscape for example has good PDF output. As for raster images PNG is the best as long as you don’t include photopraphs, then it’s good old JPEG.
In plain Latex you can only include EPS, but it depends on how the EPS was generated. EPS can contain both vector and raster images. It’s basically only a container format.

print 最常用

 

saveas 保存fig文件,圖片大小按默認設置

 saveas(gcf,'pictures\p.png')

 

saveas(gca,'myplot.eps','epsc');

Note the c in 'epsc'.

 

or 

print-depsc myplot.eps
可以試一下set(gcf, 'PaperPositionMode','auto')
我曾經用這種方法在1280*960的分辨率下保存過650*1610的圖,但是后來試一張800*2760的圖仍然是變形,也試過調整紙張大小,都沒有效果,一直很困擾,期待高手解答

 

 

imwrite 所見即所得,最快。

f=getframe(gcf);

imwrite(f.cdata,'p.ps');

 

Solution:

The best way to do this would be to export your figure into an Encapsulated PostScript (EPS) format file and then include the EPS file in the LaTeX document. You can export a figure into a EPS format using the PRINT command as follows:

plot(1:10)
print -deps epsFig

This will generate a file called epsFig.eps in your current working directory. You can then include this eps file in your LaTeX document.

One method to include an EPS figure in your LaTeX 2E document is as follows:

1. Include the following line before the \begin{document} statement

\usepackage{graphicx}

2. Use the following template code to include any figure:

\begin{figure}
\centering
\includegraphics{Figure name without .eps extension}
\caption{Insert caption}
\end{figure} 

 

 

\begin{equation} .... .... \label{eq:no1} \end{equation} ... One can see from Eq.~(\ref{eq:no1}) that ...

In a table or figure environment, the \label command should follow the \caption command (or be part of its argument) since it is the \caption command which generates the number.

 


http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics#Raster_graphics_vs._vector_graphics

要對latex插圖仔細研究,推薦Latex插圖指南一文(一般CTEX安裝目錄下help文件夾graphics.pdf就是了),下邊用雙引號括起來的都引自此書。PS:本文中代碼里的圖片文件名在編譯時請換成你的電腦里實際有的圖片,這個大家應該都懂的。
1、 我用慣word的結果是覺得Latex的圖片浮動格式很不習慣,然后我聽到這樣一段話,覺得有醍醐之感:“ 一、不要使用依賴於圖形放置位置的文本。使用如“ 這幅圖...” 或“ 下面的圖形...” 等短語要求所指的圖形需在固定位置。而像“ 圖5...” 這樣的短語則允許圖形出現在任意位置。 二、放松。一些使用者在發現圖形沒有十分准確的出現在他們所想要的位置時,往往非常着急。這沒有必要,圖形的放置是LATEX 的工作,最好放松一些。” 為什么Latex不推薦我們讓圖形准確出現在放置的位置呢?“因為那會導致糟糕的分頁,將大片的空白留在頁面下方。為得到專家級的排版效果,作者不得不手工調整圖形的位置。這種工作是非常乏味的,尤其是幾乎每次修改文檔都得這樣做一次。” Knuth同學當年做tex時,目的就是讓我們將注意力集中在文章的內容,而不是排版上。尤其是在做長文章或書時,用word每次修改時插入新的文字都要重新調整圖片,很不方便。(其實還好啦,我們的文章都短的像兔子尾巴就覺得word也挺好的) 2、 浮動格式 一個典型的插圖語句 \begin{figure}[htbp] \centering \includegraphics[width=6.5cm]{graph.eps} \caption{This is an inserted EPS graphic} \label{fig:graph} \end{figure} 其中[htbp]就是浮動格式

!強制忽略latex默認 “h here 當前位置(default)。將圖形放置在正文文本中給出該圖形環境的地方。如果本頁所剩的頁面不夠,這一參數將不起作用。 t top 頂部。將圖形放置在頁面的頂部。 b bottom 底部。將圖形放置在頁面的底部。 p page ,special page for floating object(比如最后一頁) 浮動頁。將圖形放置在一只允許有浮動對象的頁面上。” 我一般使用[htb]這樣的組合,只用[h]是沒有用的(原因請讀者思考)。這樣組合的意思就是latex會盡量滿足排在前面的浮動格式,就是h
-t-b這個順序,讓排版的效果盡量好。反正記住,放輕松。 3、 如果你就是要插在你想插的位置怎么辦? 我會這樣做:如果tex不讓你插在你想插的位置,說明你的圖片太大了,你可以試試調整[width=6.5cm]中的大小,讓它能夠插得下,其實我們在word中也是這樣做的。推薦使用\textwidth這個單位。但還是那句話,不要太勉強。 4、 一些圖片的並排 如果想要這樣的效果,要兩張圖並列,或幾張圖排在一起。可以試試下面的模板,效果請自己運行 模板一 \begin{figure}[htbp] \centering \subfigure[sin1]{\label{fig:fft:a} \begin{minipage}[c]{0.5\textwidth} \centering \includegraphics[width=6.5cm]{sin1.eps} \end{minipage}% }%注意這個”%”絕對不能省,可以試試不打%的效果 \subfigure[sin2]{ \begin{minipage}[c]{0.5\textwidth} \centering \includegraphics[width=6.5cm]{sin2.eps} \end{minipage} } \caption{fft}\label{fig:fft} \end{figure} 模板二 \begin{figure}[htbp] \centering \begin{minipage}[c]{0.5\textwidth} \centering \includegraphics[width=6.5cm]{sin1.eps} \end{minipage}% }%注意這個”%”絕對不能省,可以試試不打%的效果 \begin{minipage}[c]{0.5\textwidth} \centering \includegraphics[width=6.5cm]{sin2.eps} \end{minipage} } \caption{fft}\label{fig:fft} \end{figure} 5、 其他細節可以詳見開頭說的那本書。還有關於圖片的格式,如果用Latex編譯的話只能用eps格式的圖片,matlab就存為eps,其他用軟件轉吧,但是如果用Latex2pdf編譯的話好像就能用jpg,eps反而不可以。但推薦使用eps,我試驗下來matlab的圖eps質量好,但好像不太支持中文,其實也有辦法解決,我所知道的方法是用Psfrag宏包,詳細方法還是參見那本書,但是我覺得用英文就行了嘛。 6、 其實真正的高手latex畫圖是這樣畫的,下面一段代碼引自Arnold的一篇論文,可以運行一下,看看什么效果。 \begin{picture}(6,6) \thicklines \put(0,0){\line(1,1){6}} \put(0,6){\line(1,-1){3}} \put(1,1){\circle*{0.2}} \put(1,5){\circle*{0.2}} \put(5,5){\circle*{0.2}} \thinlines \multiput(1,1)(0,0.2){20}{\line(0,1){0.1}} \multiput(1,5)(0.2,0){20}{\line(1,0){0.1}} \put(1,5.2){\mbox{$A$}} \put(1,0.5){\mbox{$C$}} \put(4.5,5.2){\mbox{$B$}} \end{picture}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM