TikZ Notes
I got a feeling that I finally find a tool which is able to give me the ability to draw professional drawings. Always, I think those tools include PPT, KeyNote could not totally fulfil my requirements. The most critical reason shall be that I do not how to design well. So those graphs make feel not so good. Like latex, TikZ provides a way to draw graphs with just scripts. However, it takes time to learn it. Below are those points which I think useful and important.
Advantages and Disadvantages of TikZ
- Advantages
- Quick creation of graphics
- Precise positioning
- Use of macros
- Often superior typography
- Easier collaboration
- Disadvantages
- Steep learning curve
###Set up the environment \usepackage{tikz} \begin{tikzpicture} [scale = .8] \draw[->] (0,0) – (2, 0.5) node[pos = 0.5, above]{$x$}; \end{tikzpicture}
###Draw paths with coordinates \draw (1,0) – (0,1) – (-1,0) – (0,1);
###Use polar coordinates \draw (0:1) – (90:1) – (180:1) – (270:1) – cycle;
###Built-in shapes Rectangle
\draw (0,0) rectangle (1,1);
Grid
\draw[step=.5cm] (0,0) grid (3,2); ![](https://dl.dropboxusercontent.com/u/37572555/Blog/Tikz/4.png)
Circle
\draw (0,0) circle (1cm); ![](https://dl.dropboxusercontent.com/u/37572555/Blog/Tikz/5.png)
Ellipse
\draw (0,0) ellipse [x radius=1cm,y radius=.5cm]; ![](https://dl.dropboxusercontent.com/u/37572555/Blog/Tikz/6.png)
Arc
\draw (0,0) arc (0:30:3cm); ![](https://dl.dropboxusercontent.com/u/37572555/Blog/Tikz/7.png)
Bézier Curves
\draw (0,0) .. controls (1,1) and (2,1) .. (2,0); ![](https://dl.dropboxusercontent.com/u/37572555/Blog/Tikz/8.png)
###Commutative diagram Example \path[->,font=\scriptsize] (A) edge node {$\varphi$}(C) (A) edge node[auto] {$\Psi$}(B) (B) edge node[fill=white,inner sep=2pt] {$\Phi$}(C);
###Adaptive SVM diagram example
\begin{tikzpicture} [scale = 0.88]
% Auxiliary Domain
\node[circle, fill = gray!30] (one) at (0, 0) {$D^A_1$};
\node[circle, fill = gray!30] (two) at +(-90: 1.5) {$D^A_2$};
\draw[fill=black] +(-90:2.3) circle (0.05);
\draw[fill=black] +(-90:2.8) circle (0.05);
\draw[fill=black] +(-90:3.3) circle (0.05);
\node[circle, fill = gray!30] (three) at +(-90: 4) {$D^A_M$};
\node[rectangle, fill = gray!30] (cone) at (0: 2) {$f_1^A(\mathbf{x})$};
\node[rectangle, fill = gray!30] (ctwo) at (2, -1.5) {$f_2^A(\mathbf{x})$};
\draw[fill=black] +(2, -2.3) circle (0.05);
\draw[fill=black] +(2, -2.8) circle (0.05);
\draw[fill=black] +(2, -3.3) circle (0.05);
\node[rectangle, fill = gray!30] (cthree) at (2,-4) {$f_M^A(\mathbf{x})$};
\node[draw] (plus) at (5.4, -2) {$+$};
% Add edges
\draw[->, line width = 2pt] (one) -- (cone);
\draw[->, line width = 2pt] (two) -- (ctwo);
\draw[->, line width = 2pt] (three) -- (cthree);
\draw[->, line width = 2pt] (cone) -- (plus) node[pos= 0.5, sloped, above]{$t_1$};
\draw[->, line width = 2pt] (ctwo) -- (plus) node[pos= 0.5, sloped, above]{$t_2$};
\draw[->, line width = 2pt] (cthree) -- (plus) node[pos= 0.5, sloped, above]{$t_M$};
\draw[black,thick,dotted] ($(one.north west)+(-0.3,0.6)$) rectangle ($(plus.south east)+(0.3,-2.6)$);
\node (auxiliary) at ( 4.4, 0.4) {Auxiliary Domain};
% Target Domain
\node[circle, fill = gray!30] (t) at (0, -5.8) {$D^T_l$};
\node[rectangle, fill = gray!30] (tF) at (3, -5.8) {$\Delta f(\mathbf{x}) = w^T \phi(x)$};
\node[draw](plus2) at (6.7,-2.9) {$+$};
\draw[->, line width = 2pt] (t) -- (tF);
\draw[->, line width = 2pt] (plus) -- (plus2);
\draw[->, line width = 2pt] (tF) .. controls +(right: 3) .. (plus2);
\draw[black,thick,dotted] ($(t.north west)+(-0.3,0.2)$) rectangle ($(tF.south east)+(0.3,-1)$);
\node (target) at (2, -6.7) {Target Domain};
% Decision Function
\node[rectangle] (df) at (8.2, -2.9) {$f(\mathbf{x})=$};
\node[fill = blue!30](partOne) at (10.2, -2.9) {$\sum_{k=1}^M t_k f_{k}^A(\mathbf{x})$};
\node[fill= red!30](partTwo) at (12.6, -2.9) {$ \Delta f(\mathbf{x})$};
\node at (11.8, -2.9) {$+$};
\draw[->, line width = 2pt] (plus2) -- (df);
% Two key points of decision function
\node (keyOne) at (10.2, -1.5) {separates the labeled examples in $D^T_l$ well};
\node (keyTwo) at (9.7, -5) {seeks a hyperplane which is close to};
\node (keyThree) at (9.8, -5.5) {the boundaries of auxiliary classifiers.};
\draw[->, line width = 2pt] (keyOne) -- (partTwo);
\draw[->, line width = 2pt] (keyTwo) -- (partOne);
\end{tikzpicture}. ![](https://dl.dropboxusercontent.com/u/37572555/Blog/Tikz/10.png)