Tags: , ,

TikZ2SVG

TikZ2SVG is a Perl script that converts TikZ to SVG.

1   Grids

Uniqki code
Inline
::tikz2svg::small:inline:---
\tikz \draw[x=1.57ex,y=1ex,green] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0)
(0,1) cos (1,0) sin (2,-1) cos (3,0) sin (4,1);
---
demo
Uniqki output

Inlinesmalldemo

Uniqki code
::tikz2svg::grids::---
\begin{tikzpicture}[scale=1.5,font=\Large]
  \draw (0,0) grid (3,3);
  \draw
    (0.5,2.5) node {0} (1.5,2.5) node {0} (2.5,2.5) node {$q=1$}
    (0.5,1.5) node {0} (1.5,1.5) node {1} (2.5,1.5) node {0}
    (0.5,0.5) node {$p=1$} (1.5,0.5) node {0} (2.5,0.5) node {0};
  \draw[red,thick]
    (0.7,0.7)--(1.3,1.3)
    (1.7,1.7)--(2.3,2.3);
  \draw (1.5,0) node[below] {$D_m=2$};

  \draw[xshift=3.5cm] (0,0) grid (3,3);
  \draw[xshift=3.5cm]
    (0.5,2.5) node {0} (1.5,2.5) node {0} (2.5,2.5) node {$q=1$}
    (0.5,1.5) node {1} (1.5,1.5) node {1} (2.5,1.5) node {0}
    (0.5,0.5) node {$p=1$} (1.5,0.5) node {0} (2.5,0.5) node {0};
  \draw[red,thick,xshift=3.5cm]
    (0.5,0.7)--(0.5,1.3)
    (0.7,1.5)--(1.3,1.5)
    (1.7,1.7)--(2.3,2.3);
  \draw[xshift=3.5cm] (1.5,0) node[below] {$D_m=3$};

  \draw[xshift=7cm] (0,0) grid (3,3);
  \draw[xshift=7cm]
    (0.5,2.5) node {0} (1.5,2.5) node {1} (2.5,2.5) node {$q=1$}
    (0.5,1.5) node {0} (1.5,1.5) node {1} (2.5,1.5) node {0}
    (0.5,0.5) node {$p=1$} (1.5,0.5) node {0} (2.5,0.5) node {0};
  \draw[red,thick,xshift=7cm]
    (0.7,0.7)--(1.3,1.3)
    (1.5,1.7)--(1.5,2.3)
    (1.7,2.5)--(2.05,2.5);
  \draw[xshift=7cm] (1.5,0) node[below] {$D_m=3$};

  \draw[xshift=10.5cm] (0,0) grid (3,3);
  \draw[xshift=10.5cm]
    (0.5,2.5) node {0} (1.5,2.5) node {1} (2.5,2.5) node {$q=1$}
    (0.5,1.5) node {1} (1.5,1.5) node {1} (2.5,1.5) node {0}
    (0.5,0.5) node {$p=1$} (1.5,0.5) node {0} (2.5,0.5) node {0};
  \draw[red,thick,xshift=10.5cm]
    (0.5,0.7)--(0.5,1.3)
    (0.7,1.5)--(1.3,1.5)
    (1.5,1.7)--(1.5,2.3)
    (1.7,2.5)--(2.05,2.5);
  \draw[xshift=10.5cm] (1.5,0) node[below] {$D_m=4$};
\end{tikzpicture}
---
Uniqki output

grids

2   Plotting

Uniqki code
::tikz2svg::plots::----
\documentclass{standalone}
\usepackage{tikz}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\begin{document}
\begin{tikzpicture}[domain=-2:2,samples=100,scale=1.0,>=latex]
\tikzset{bgrid/.style={help lines,color=blue!10,very thin}}

\draw[bgrid] (-1.5,-3.5) grid (7.5,3.5);

\draw[<->, color=black] (-1.5,0) -- (7.5,0) node[right] {$x$};
\draw[<->, color=black] (0,-3.5) -- (0,3.5) node[above] {$y$};

\foreach \x/\xtext in {-1,1,2,3,4,5,6,7}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\xtext$};

\foreach \y/\ytext in {-3,-2,-1,1,2,3}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\ytext$};

\draw[thick,color=black,domain=0:7.5,smooth]
plot (\x,{sqrt(\x)}) node[anchor=south] {$y = \sqrt{x}$};
\draw[dashed,color=black,domain=0:7.5,smooth]
plot (\x,{(-1)*(sqrt(\x))}) node[anchor=north] {$y = -\sqrt{x}$};
\draw[thick,color=black,domain=-1.5:5.5,samples=3]
plot (\x,{(\x)-2}) node[anchor=south] {$y = x - 2$};

\filldraw[black] (4,2) circle(2pt) node[anchor=south east] {$(4, 2)$};
\filldraw[red] (1,-1) circle(2pt);
\draw[red] (1.5,-1) node[anchor=west] {$(1, -1)$};

\end{tikzpicture}
\end{document}
----
Uniqki output

plots