Skip to content

Commit

Permalink
add tikz
Browse files Browse the repository at this point in the history
  • Loading branch information
tlming16 committed Mar 7, 2022
1 parent 9f9daec commit bf12d24
Show file tree
Hide file tree
Showing 20 changed files with 1,051 additions and 0 deletions.
8 changes: 8 additions & 0 deletions LaTeX/tikz/an.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{animations}

\begin{document}

\tikz \node [fill, text = white, animate = {myself:fill = {0s = "red", 2s = "blue", begin on = click }}] {Click me};
\end{document}
25 changes: 25 additions & 0 deletions LaTeX/tikz/chains.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
\documentclass{standalone}
%\url{http://tex.stackexchange.com/q/141259/86}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[start chain=circle placed {at=(\tikzchaincount*30:1.5)},regular/.style={draw,circle,inner sep=0,minimum size=4mm}]
\foreach \i in {0,...,11}
\node [on chain, regular] (\i) {\i};
\foreach[evaluate=\i as \ni using {int(mod(\i+1,12))}] \i in {0,...,11}
\draw [->] (\i) to (\ni);
\end{tikzpicture}
\begin{tikzpicture}[
declare function={
excitation(\t,\w) = sin(\t*\w);
noise = rnd - 0.5;
source(\t) = excitation(\t,20) + noise;
filter(\t) = 1 - abs(sin(mod(\t, 90)));
speech(\t) = 1 + source(\t)*filter(\t);
}
]
\draw [help lines] (0,0) grid (3,2);
\draw [blue, thick, x=0.0085cm, y=1cm] (0,1) --
plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});
\end{tikzpicture}
\end{document}
17 changes: 17 additions & 0 deletions LaTeX/tikz/external.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}
115 changes: 115 additions & 0 deletions LaTeX/tikz/gp.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
\documentclass{article}
\usepackage{tikz}
\usepackage{animate}
\usepackage{amsmath}
\usepackage{ifthen}
\usepackage{pgfmath}
\usetikzlibrary {matrix}
\usepackage{tikzlings}
\usepackage{tikzlings-penguins}
\usepackage{graphics,graphicx}

\newcommand{\token}{
\begin{scope}[node distance=0pt]
\node[ rectangle,fill=red] at (0,0) {};
\node[ rectangle,fill=red!20] at (1,0) {};
\node[ rectangle,fill=red!40] at (2,0) {};
\node[ rectangle,fill=blue!20] at (3,0) {};
\node[ rectangle,fill=blue!40] at (4,0) {};
\node[ rectangle,fill=blue] at (5,0) {};
\end{scope}
}
\begin{document}
\begin{figure}
\begin{tikzpicture}[>=latex,domain=-0.3:1.2]
\xdef\a{0.125}
\xdef\b{0.5}
\xdef\scale{1.2}
\xdef\ppos{-0.6}
\begin{scope}
\draw[->] (-0.5,0) -- (1.6,0) node[right] {$x$};
\draw[->] (0,-0.3)--(0,1.2) node[right] {$y$};
\node (a) at (\a,-0.15) {$a$};
\node (b) at (\b,-0.15) {$b$};
\node (o) at (-0.2,-0.1){ $o$};
\draw plot (\x,{\scale*abs(\x-\a)*abs(\x-\b)});
\end{scope}
\begin{scope}[xshift=2.5cm]
\draw[->] (-0.3,0) -- (1.6,0) node[right] {$x$};
\draw[->] (0,-0.3)--(0,1.2) node[right] {$y$};
\node (a) at (\a,-0.15) {$a$};
\node (b) at (\b,-0.15) {$b$};
\node (o) at (-0.2,-0.1){ $o$};
\draw plot (\x,{\scale*abs(\x-\a)*(\x-\b)});
\end{scope}
\begin{scope}[xshift=5cm]
\draw[->] (-0.3,0) -- (1.6,0) node[right] {$x$};
\draw[->] (0,-0.3)--(0,1.2) node[right] {$y$};
\node (a) at (\a,-0.15) {$a$};
\node (b) at (\b,-0.15) {$b$};
\node (o) at (-0.2,-0.1){ $o$};
\draw plot (\x,{\scale(\x-\a)*abs(\x-\b)});
\end{scope}
\begin{scope}[xshift=7.5cm,domain=-0.5:1]
\draw[->] (-0.6,0) -- (1.2,0) node[right] {$x$};
\draw[->] (0,-0.3)--(0,1.2) node[right] {$y$};
\node (a) at (\a,-0.15) {$a$};
\node (b) at (\b,-0.15) {$b$};
\node (o) at (-0.2,-0.1){ $o$};
\draw plot (\x,{\scale*-1*abs(\x-\a)*(\x-\b)});
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[>=latex,domain=-3:3,x=0.5cm,y=2cm]
\pgfmathparse{ {1.0/sqrt{2*pi}/4}}
\let\ymax\pgfmathresult
\xdef\mr{1.8}
\draw[->] (-3.2,0)--(3.4,0) node[right] {$x$};
\draw[->] (0,-0.1) --(0,\ymax) node[above] {$y$};
\draw[smooth,samples=100] plot (\x,{exp(-\x *\x/2)/sqrt(2*pi)});
\filldraw[fill=gray,domain=\mr:3] (\mr,0) node[below] {$\alpha$} -- plot (\x,{exp(-\x *\x/2)/sqrt(2*pi)}) --(3,0)--cycle;
\end{tikzpicture}
\end{figure}
\begin{center}
\begin{figure}
\begin{tikzpicture}[>=latex,x=0.5cm,y=2cm]
\draw[->] (-1,0) --(4,0) node[right] {$x$};
\draw[->] (0,-0.2) --(0,1) node[above] {$y$};
\foreach \ll[evaluate=\ll as \c using 10*\ll] in {1,2,3,4}{
\draw[domain=0.4:3,smooth,red!\c!blue] plot (\x, { \ll*exp(\ll*-\x)});
}
\end{tikzpicture}
\begin{tikzpicture}
\draw[->] (-1.2,0) --(1.3,0) node[right] {$x$};
\draw[->] (0,-0.2) --(0,1.2) node[above] {$y$};
\foreach \a in {1/2,1.1,2}{
\draw[domain=-1:1,smooth] plot(\x, {\a*\x*\x}) node[right] {$\a x^2$};
}
\end{tikzpicture}
\end{figure}
\end{center}

\begin{animateinline}[poster=first,autoplay, palindrome]{4}
\multiframe{3}{iangle=5+5}{
\begin{tikzpicture}[>=latex,x=0.5cm,y=2cm]
\draw[->] (-1,0) --(4,0) node[right] {$x$};
\draw[->] (0,-0.2) --(0,1) node[above] {$y$};
\pgfmathparse{\iangle/5}
\let\ll\pgfmathresult
\draw[domain=0.4:3,smooth,red!\iangle!blue] plot (\x, { \ll*exp(\ll*-\x)}) node[above right]{$\ll e^{-\ll x}$} ;
\end{tikzpicture}
}
\end{animateinline}
\begin{tikzpicture}[>=latex]
\draw [->] (-5,0) --(5.2,0) node[below right]{$x_1$};
\draw[->] (0,-5) --(0,5.2) node[above left] {$x_2$};
\foreach \r in {1,2,3,4}{
\draw[blue,thick] (0,0) circle[radius=\r] ;
}
\pgfmathparse{sqrt(2)*2}
\let\ss\pgfmathresult
\draw [domain=-3:5,smooth,thick,red] plot(\x,{-\x + \ss}) node[below right] {$g(x_1,x_2)=0$};
\end{tikzpicture}
\begin{tikzpicture}
\token ;
\end{tikzpicture}
\end{document}
7 changes: 7 additions & 0 deletions LaTeX/tikz/latex.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\documentclass{standalone}
\usepackage{graphicx,graphics}
\usepackage{tikz}
\begin{document}

\includegraphics[width=0.8\textwidth]{match_doll.png}
\end{document}
68 changes: 68 additions & 0 deletions LaTeX/tikz/matrix.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
\documentclass{standalone}
\usepackage{tikz}
\usepackage{animate}
\usepackage{ifthen}
\usetikzlibrary {matrix}
\usepackage{tikzlings}
\usepackage{tikzlings-penguins}

\begin{document}
\begin{tikzpicture}
\matrix (a) [matrix of math nodes,left delimiter=(,right delimiter=)]
{
a_8 & a_1 & a_6 \\
a_3 & a_5 & a_7 \\
a_4 & a_9 & a_2 \\
};
\node at (a.west) [xshift=-0.5cm] {$P=$};
\end{tikzpicture}
\begin{animateinline}[poster=first,autoplay, palindrome]{12}
\multiframe{29}{iangle=80+10, rdim=2.0+-0.2}{
\begin{tikzpicture}[scale=0.1]
\fill[blue] (\iangle+45:\rdim) - - (\iangle+135:.5)- -
(\iangle+225:\rdim)- -(\iangle+315:.5) - - cycle;
\fill[blue] (\iangle+45:.5) - - (\iangle+135:\rdim)- - (\iangle+
225:.5)- -(\iangle+315:\rdim) - - cycle;
\end{tikzpicture} }
\end{animateinline}

\begin{animateinline}[poster=first,autoplay, palindrome]{12}
\multiframe{29}{iangle=2+1}{
\begin{tikzpicture}[scale=1]
\draw[domain=0:1.2] plot (\x,\x*\x) node[right] {$f(x)=x^2$};
\draw[->] (0,0) --(1.5,0) node[right] {$x$};
\draw[->] (0,-0.1) --(0,1.5) node[above] {$y$};
\foreach \i in {0,1,...,\iangle} {
\xdef \dx {1.0/\iangle}
\xdef \x {\i *\dx}
\xdef \s {2}
\pgfmathparse{\i<\iangle?1:6}
\let\s\pgfmathresult
\filldraw[blue] (\x,0) -- (\x,\x*\x) --(\x+\dx/\s,\x*\x) --(\x+\dx/\s,0)--cycle;
}
\end{tikzpicture}
}
\end{animateinline}

\begin{animateinline}[poster=first,autoplay, palindrome]{12}
\multiframe{15}{iangle=2+1}{
\begin{tikzpicture}[scale=0.5]
\foreach \i in {0,2,...,\iangle} {
\xdef\dx{\i}
\pgfmathparse{\dx/4}
\let\s\pgfmathresult
\draw[blue] (0,0) circle( \s);
}
\end{tikzpicture}
}
\end{animateinline}

\begin{animateinline}[poster=first,autoplay, palindrome]{4}
\multiframe{13}{iangle=0+1}{
\begin{tikzpicture}[scale=0.2]
%\draw[blue] (0,0) circle( \s);
\ifthenelse{\isodd{\iangle}}{\penguin[rotate=-30,scale=0.4]; \penguin[xshift=1cm,rotate=30,scale=0.3];} { \penguin[rotate=-30,scale=0.4]; \penguin[rotate=30,xshift=1cm,scale=0.3]}
\end{tikzpicture}
}
\end{animateinline}
\end{document}
33 changes: 33 additions & 0 deletions LaTeX/tikz/mc.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
\documentclass{standalone}
\usepackage{ctex}
\usepackage{tikz}
\usetikzlibrary {decorations,arrows.meta,automata,positioning,shadows}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}
\begin{document}
\begin{tikzpicture}[->,>={Stealth[round]},
shorten >=1pt,auto,node distance=1.8cm,on grid,semithick, %
every state/.style={fill=blue!40,draw=none,circular drop shadow,text=white},%
mid arrow/.style={postaction={decorate,decoration={
markings,mark=at position .5 with {\arrow[red]{Stealth[round]}}}}}]
\node[state] (A) at (0,0) {$S_1$};
\node[state] (B) at (3,2) {$S_2$};
\node[state] (C) at (3,-2) {$S_3$};
\draw[mid arrow] (A.east) to [bend left=15] node{$0.28$} (B.south);
\draw[mid arrow] (A.east) to [bend left=15] node[left] {$0.07$ } (C.north);
\draw[mid arrow] (B.south) to [bend left=15] node[right] {$0.18$} (C.north);
\draw[mid arrow] (B.south) to [bend left=15] node[left] {$0.15$} (A.east);
\draw[mid arrow] (C.north) to [bend left=15] node {$0.12$} (A.east);
\draw[mid arrow] (C.north) to [bend left=15] node {$ 0.36$} (B.south);
\draw (A) edge [loop left] node {$0.65$} (A);
\draw (B) edge[loop above] node {$0.67$} (B);
\draw (C) edge[loop below] node {$0.52$} (C);
\begin{scope}[xshift=6cm,yshift=0.5cm]
\matrix[nodes={minimum size=5mm}]{
&\node[red]{0.65}; &\node{0.28}; &\node{0.07};\\
\node[red]{$P=$};& \node{0.15}; &\node[red]{0.67}; &\node{0.18}; \\
& \node{0.12}; &\node{0.36}; &\node[red]{0.52} ;\\
}
;
\end{scope}
\end{tikzpicture}
\end{document}
109 changes: 109 additions & 0 deletions LaTeX/tikz/mv.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
\documentclass{article}
\usepackage[]{graphicx}
\usepackage[]{color}
\usepackage{geometry}
\usepackage{tikz}
\usepackage{tikzit}
\usepackage{multimedia}

\begin{document}
\tikzstyle{bg}=[-, line width=0.5mm, fill={rgb,255: red,217; green,217; blue,217}]
\tikzstyle{fg}=[-, fill=black]
\tikzstyle{dir}=[->]
\tikzstyle{region A}=[-, draw=none, fill={rgb,255: red,255; green,160; blue,162}, opacity=0.8]
\tikzstyle{region B}=[-, draw=none, fill={rgb,255: red,190; green,185; blue,255}, opacity=0.8]
\tikzstyle{region C}=[-, fill={rgb,255: red,179; green,255; blue,192}, draw=none, opacity=0.8]
\begin{figure}
\begin{tikzpicture}
\node [red,circle] (0) at (-5.25, 2.75) {};
\node [red,circle] (1) at (-3.75, 2.75) {};
\node [red,circle] (2) at (-3.75, 2.75) {};
\node [red,circle] (3) at (-4.75, 5.25) {};
\node [red,circle] (4) at (10.5, 28.75) {x};
\end{tikzpicture}
\tikzstyle{bg}=[-, line width=0.5mm, fill={rgb,255: red,217; green,217; blue,217}]
\tikzstyle{fg}=[-, fill=black]
\tikzstyle{dir}=[->]
\tikzstyle{region A}=[-, draw=none, fill={rgb,255: red,255; green,160; blue,162}, opacity=0.8]
\tikzstyle{region B}=[-, draw=none, fill={rgb,255: red,190; green,185; blue,255}, opacity=0.8]
\tikzstyle{region C}=[-, fill={rgb,255: red,179; green,255; blue,192}, draw=none, opacity=0.8]
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (5) at (-0.5, -1.25) {};
\node [style=none] (6) at (0.5, 1.25) {};
\node [style=none] (7) at (1.25, 0.5) {};
\node [style=none] (8) at (1.25, 2) {};
\node [style=none] (9) at (2, 1.25) {};
\node [style=none] (10) at (2.75, 2) {};
\node [style=none] (11) at (2, 2.75) {};
\node [style=none] (18) at (1.25, -2) {};
\node [style=none] (20) at (2.75, -2) {};
\node [style=none] (22) at (2, -2.75) {};
\node [style=none] (23) at (2, -1.25) {};
\node [style=none] (26) at (-2.75, -2) {};
\node [style=none] (28) at (-1.25, -2) {};
\node [style=none] (30) at (-2, -2.75) {};
\node [style=none] (31) at (-2, -1.25) {};
\node [style=none] (32) at (0.5, -1.25) {};
\node [style=none] (33) at (-1.25, -0.5) {};
\node [style=none] (35) at (1.25, -0.5) {};
\node [style=none] (36) at (-0.5, 1.25) {};
\node [style=none] (37) at (-1.25, 0.5) {};
\node [style=none] (65) at (0, 3) {};
\node [style=none] (69) at (0.775, -2.9) {};
\node [style=none] (70) at (2, -3.5) {};
\node [style=none] (71) at (3.5, -2) {};
\node [style=none] (72) at (2.9, -0.775) {};
\node [style=none] (80) at (-3, 0) {};
\node [style=none] (81) at (-0.775, -2.9) {};
\node [style=none] (82) at (-2, -3.5) {};
\node [style=none] (83) at (-3.5, -2) {};
\node [style=none] (84) at (-2.9, -0.775) {};
\node [style=none] (85) at (0.775, 2.9) {};
\node [style=none] (86) at (2, 3.5) {};
\node [style=none] (87) at (3.5, 2) {};
\node [style=none] (88) at (2.9, 0.775) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=bg] (72.center)
to [in=90, out=-30, looseness=0.75] (71.center)
to [in=0, out=-90] (70.center)
to [in=-60, out=180, looseness=0.75] (69.center)
to [in=-15, out=-165] (81.center)
to [in=0, out=-120, looseness=0.75] (82.center)
to [in=-90, out=180] (83.center)
to [in=-150, out=90, looseness=0.75] (84.center)
to [in=-90, out=105, looseness=0.75] (80.center)
to [in=-180, out=90] (65.center)
to [in=165, out=0, looseness=0.75] (85.center)
to [in=-180, out=60, looseness=0.75] (86.center)
to [in=90, out=0] (87.center)
to [in=30, out=-90, looseness=0.75] (88.center)
to [in=75, out=-75] cycle;
\draw [style=fg] (36.center)
to [in=135, out=45] (6.center)
to [in=-90, out=-45, looseness=1.25] (8.center)
to [in=-180, out=90] (11.center)
to [in=90, out=0] (10.center)
to [in=0, out=-90] (9.center)
to [in=135, out=180, looseness=1.25] (7.center)
to [in=45, out=-45] (35.center)
to [in=180, out=-135, looseness=1.25] (23.center)
to [in=90, out=0] (20.center)
to [in=0, out=-90] (22.center)
to [in=-90, out=180] (18.center)
to [in=45, out=90, looseness=1.25] (32.center)
to [in=-45, out=-135, looseness=1.25] (5.center)
to [in=90, out=135, looseness=1.25] (28.center)
to [in=0, out=-90] (30.center)
to [in=-90, out=180] (26.center)
to [in=-180, out=90] (31.center)
to [in=-45, out=0, looseness=1.25] (33.center)
to [in=-135, out=135] (37.center)
to cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{figure}


\end{document}
Loading

0 comments on commit bf12d24

Please sign in to comment.