lz这个图比较简单,直接用裸的cairo api都能画出来,就是要算坐标。。。。
tikz学起来其实不难,麻烦的地方在于有时候也要算坐标,那就蛋疼了.
R->Tikz:
http://cran.r-project.org/web/packages/ ... index.html
Matlab Fig -> PDF:
http://www.mathworks.com/matlabcentral/ ... -exportfig
这样导出好处是生成的都是矢量而非位图。
[latex]
%%% normalDistr.tex ---
%% Version: $Id: normalDistr.tex,v 0.0 2012/01/05 14:35:11 tangboyun Exp$
%% Copyright : (c) 2012 Boyun Tang
%% License : BSD-style
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap,shadows,shapes.arrows,shapes.geometric,shapes.misc,matrix,arrows,positioning,calc,decorations.pathreplacing}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{verbatim}
\begin{document}
\begin{tikzpicture}[domain=0:3.5,scale=1.5,samples=500]
\draw[very thin,color=gray!30,step=0.1] (-0.1,-0.1) grid (3.5,1.7);
\draw[->] (-0.2,0) -- (3.5,0) node[right,font=\small] {$\mathit{x}$};
\draw[->] (0,-0.2) -- (0,1.7) node[above,font=\small] {$\mathit{p(x)}$};
\draw
plot (\x,{1 / (2.486*0.3) * exp(-0.5*((\x - 1)/0.3) * ((\x - 1)/0.3))});
\draw[very thin,color=blue,loosely dashed] (1,-0.2) -- (1,1.7);
\draw[very thin,color=red,loosely dashed] (2.2,-0.2) -- (2.2,1.7);
\draw
plot (\x,{1 /(0.35 * 2.486) * exp(-0.5*((\x - 2.2) /0.35) * ((\x - 2.2) / 0.35))});
\foreach \x/\xtext in {0.5,1,1.5,2.0,2.5,3.0}
\draw (\x, 1pt) -- (\x, -1pt) node [anchor=north,font=\tiny] {$\xtext$};
\foreach \y/\ytext in {0.5,1,1.5}
\draw (1pt,\y) -- (-1pt,\y) node [anchor=east,font=\tiny] {$\ytext$};
\draw (1.75,1.7) node [anchor=south,font=\tiny] {\(
p(x)=\frac{1}{\sqrt{2\mathrm{\pi}}\sigma}
\mathrm{e}^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^2}
\)};
\draw (2.25,1.5) node [anchor=south west,color=blue,font=\tiny] {\(
\mu_1 = 1,\sigma_1 = 0.3\)};
\draw (2.25,1.37) node [anchor=south west,color=red,font=\tiny] {\(
\mu_2 = 2.2,\sigma_2 = 0.35\)};
\end{tikzpicture}
\end{document}
[/latex]
[latex]
%%% nonlinerSVM.tex ---
%% Version: $Id: test.tex,v 0.0 2012/01/05 14:21:36 tangboyun Exp$
%% Copyright : (c) 2012 Boyun Tang
%% License : BSD-style
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap,shadows,shapes.arrows,shapes.geometric,shapes.misc,matrix,arrows,positioning,calc,decorations.pathreplacing}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{verbatim}
\begin{document}
\begin{tikzpicture}[
a/.style={ball color=blue,circle},
b/.style={ball color=red,circle},
]
\draw (8,1) node {};
\draw (9,2) node {};
\draw (12,2.2) node {};
\draw (9.2,0.5) node {};
\draw (10.3,0.8) node {};
\filldraw[draw=green!40,fill=green!40,fill opacity=0.8] (7,1) -- (9,3.5) -- (13,4)
--(11,1.5)--cycle;
\draw [dashed] (7,0) -- (9,1.5) -- (13,1.5);
\draw [dashed] (9,5.5) -- (9,1.5);
\draw (7.5,1.5) node [a] {};
\draw (9.2,3.5) node [a] (f1) {};
\draw (12,4.3) node [a] {};
\draw (10.5,3) node [a] {};
\draw (8.8,2.5) node [a] {};
\draw[thick] (0,0) -- (2,2) -- (6,2) -- (4,0) -- (0,0);
\draw[thick] (7,4) -- (9,5.5) -- (13,5.5) -- (11,4) -- (7,4) -- (7,0) -- (11,0) -- (11,4);
\draw[thick] (11,0) -- (13,1.5) -- (13,5.5);
\draw (1,0.5) node [a] {};
\draw (1.8,0.25) node {};
\draw (2.2,1.75) node [a] (a1) {};
\draw (2.3,1) node {};
\draw (3,1.2) node [a] {};
\draw (2.7,0.35) node {};
\draw (4,1.6) node [a] {};
\draw (3.5,0.6) node {};
\draw (4.5,0.9) node {};
\draw (5,1.5) node [a] {};
\draw [thick,green!70,rounded corners] (1.2,0) -- (1.4,0.38) -- (2.25,1.38) -- (2.85,0.78) -- (3.8,1.1) -- (4.75,1.2) -- (5,1);
\draw (a1)
edge [->,very thick,bend left] node [midway,above,font=\huge] {$\boldsymbol{\phi}$}
(f1);
\draw (3,-0.5) node [font=\Large,yshift=-5pt]{\textbf{Input Space}};
\draw (10,-0.5) node[font=\Large,yshift=-5pt] {\textbf{Feature Space}};
\end{tikzpicture}
\end{document}
[/latex]