Elmag Seminar Tikz Ver1.2
Elmag Seminar Tikz Ver1.2
Elmag Seminar Tikz Ver1.2
Michal Mašek
michal.masek@fel.cvut.cz
Departmental seminars
May 7 and 14, 2019
Outline
1. Introduction
2. Figures with TikZ
3. Graphs in LATEX- pgfplots
4. Drawing in Graphs
1 M. Masek, “Coaxial Cable,” Bachelor Thesis, Czech Technical University in Prague, Czech Republic, 2013.
Michal Mašek Graphics in LATEX 2 / 30
Introduction
Introduction
Use Google!
Every problem you have, someone else already solved...
Draw figures with tikz package2 . Plot graphs with pgfplot package2 .
270
Cz2
ψ3 σvxz 180
E
T1
T2
150
ψ4 120
ψ5
90
σvyz 1 3 5 7 9
electrical size ka
11 13 15
2 M. Masek, M. Capek, L. Jelinek, and K. Schab, “Modal Tracking Based on Group Theory,” submited to
Outline
1. Introduction
w
2. Figures with TikZ
3. Graphs in LATEX- pgfplots
4. Drawing in Graphs
l
h
PIFA structure3 .
3 M. Masek, J. Rymus, P. Hazdra and M. Capek, “Implementation of the Theory of Characteristic Modes
into Antenna Modeling Tools and Their Benchmarking,” 8th Microwave and Radar Week, Poznan, Poland,
2018.
Michal Mašek Graphics in LATEX 5 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
The solution.
Michal Mašek Graphics in LATEX 7 / 30
Figures with TikZ
text
The solution.
above
left right
below
The solution.
The solution.
circ
circ XXX
The solution.
circ
circ XXX
The solution.
circ
circ XXX
The solution.
circ
circ XXX
The solution.
circ
circ XXX
The solution.
The solution.
Free space
% Free space
\coordinate (air1) at ($(ant1B) + (2* \antennaX, 0)$);
\coordinate (air2) at ($(ant2B) + (-2* \antennaX, 0)$);
\draw[arrow, cyan, dashed] (air1) -- (air2);
\node[cyan, below] at ($(air1) !0.5! (air2)$) {Free space};
\end{tikzpicture}
r ra
r ab
a b
r rr0
r br0
r0
Vectors adding.
GeoGebra application.
circuitikz
\usepackage[europeanresistors]{circuitikz}
I Documentation: I circuitikz % ...
I Predefined styles for electrical and
electronic networks.
circuitikz
\usepackage[europeanresistors]{circuitikz}
I Documentation: I circuitikz % ...
\begin{circuitikz}
I Predefined styles for electrical and \end{circuitikz}
electronic networks.
I circuitikz environment.
circuitikz
\usepackage[europeanresistors]{circuitikz}
I Documentation: I circuitikz % ...
\begin{circuitikz}
I Predefined styles for electrical and \draw (0, 0) to[R=$R 0$] (2, 0);
electronic networks. \end{circuitikz}
I circuitikz environment.
I \to command.
R0
The solution.
circuitikz
\usepackage[europeanresistors]{circuitikz}
I Documentation: I circuitikz % ...
\begin{circuitikz}
I Predefined styles for electrical and \draw (0, 0) to[short, o-] (0, 0);
electronic networks. \draw (0, 0) to[R=$R 0$] (2, 0);
I circuitikz environment. \draw (2, 0) to[short,-*] ++(0,0);
I \to command. \end{circuitikz}
R0
The solution.
circuitikz
\usepackage[europeanresistors]{circuitikz}
I Documentation: I circuitikz % ...
\begin{circuitikz}
I Predefined styles for electrical and \draw (0, 0) to[short, o-] (0, 0);
electronic networks. \draw (0, 0) to[R=$R 0$] (2, 0);
I circuitikz environment. \draw (2, 0) to[short,-*] ++(0,0);
I \to command. \draw (2, 0) to[R=$R 1$] ++(2, 0);
\draw (4, 0) to[short,-*] ++(0,0);
\end{circuitikz}
R0 R1
The solution.
circuitikz
\usepackage[europeanresistors]{circuitikz}
I Documentation: I circuitikz % ...
\begin{circuitikz}
I Predefined styles for electrical and \draw (0, 0) to[short, o-] (0, 0);
electronic networks. \draw (0, 0) to[R=$R 0$] (2, 0);
I circuitikz environment. \draw (2, 0) to[short,-*] ++(0,0);
I \to command. \draw (2, 0) to[R=$R 1$] ++(2, 0);
\draw (4, 0) to[short,-*] ++(0,0);
C \draw (2, 0) --++ (0, 1.2) to[C=$C$]
++(2, 0) --++ (0, -1.2);
\draw (2, 0) --++ (0, -1.2) to[L=$L$]
++(2, 0) --++ (0, 1.2);
R0 R1 \draw (4, 0) to[short,-o] ++(0.5,0);
\end{circuitikz}
L
The solution.
% first LC block
\node[myBlock, rotate=270] (recA) at (2.25,0) {
\begin{circuitikz}
\draw (0,0) to[L] (0,2);
\draw (1,0) to[C] (1,2);
\end{circuitikz}
};
Outline
1. Introduction
20
2. Figures with TikZ
3. Graphs in LATEX- pgfplots
10
4. Drawing in Graphs
λn
0
modes 1 – 3
modes 4 – 6
−10
modes 7 – 11
modes 12 – 16
higher modes
−20
0.5 1 1.5 2 2.5 3 3.5 4
ka
Characteristic numbers of spherical shell3 .
3 M. Masek, J. Rymus, P. Hazdra and M. Capek, “Implementation of the Theory of Characteristic Modes
into Antenna Modeling Tools and Their Benchmarking,” 8th Microwave and Radar Week, Poznan, Poland,
2018.
Michal Mašek Graphics in LATEX 20 / 30
Graphs in LATEX- pgfplots
I Plot in Matlab:
sin(x), cos(x)
0.2
cos(x)’) -0.6
-0.8
-1
0 1 2 3 4 5 6 7
x
sin(x), cos(x)
I Plot in Matlab:
x = linspace(0, 2*pi, 101);
plot(x, sin(x), x, cos(x));
0
xlabel(’x’), ylabel(’sin(x),
cos(x)’) −0.5
I Export to tex tex.
matlab2tikz(’mySinAndCos.tex’);
−1
I matlab2tikz 0 2 4 6
I The content of the .tex file can be: x
I inserted into thesis / paper /
presentation.
I used in standalone document → get Graph exported to LATEX.
the graph as pdf → insert it as image.
matlab2tikz
\begin{axis}[
width=4cm,
I What is in the File? height=3cm,
I Axis setting. at={(0.758in,0.481in)},
scale only axis,
xmin=0,
xmax=7,
xlabel style={font=\color{white!15!black}},
xlabel=x,
ymin=-1,
ymax=1,
ylabel style={font=\color{white!15!black}},
ylabel={sin(x), cos(x)},
axis background/.style={fill=white}
]
matlab2tikz
\definecolor{mycolor1}{rgb}{0.12157,0.47059,0.70588}
\addplot [color=mycolor1, forget plot]
I What is in the File? table[row sep=crcr]{%
I Axis setting. 0 0\\
I Curves setting and data. 0.0628318530717959 0.0627905195293134\\
0.125663706143592 0.125333233564304\\
0.188495559215388 0.187381314585725\\
0.251327412287183 0.248689887164855\\
0.314159265358979 0.309016994374947\\
% ... 101 points of the first curve ...
};
\definecolor{mycolor2}{rgb}{0.20000,0.62745,0.17255}
\addplot [color=mycolor2, forget plot]
table[row sep=crcr]{%
0 1\\
0.0628318530717959 0.998026728428272\\
0.125663706143592 0.992114701314478\\
0.188495559215388 0.982287250728689\\
0.251327412287183 0.968583161128631\\
0.314159265358979 0.951056516295154\\
% ... 101 points of the second curve ...
};
matlab2tikz
matlab2tikz
\documentclass[tikz]{standalone}
% ... some packages imported ...
I What is in the File? \begin{document}
I Axis setting. \definecolor{mycolor1}{rgb}{0.12157,0.47059,0.70588}
I Curves setting and data. \definecolor{mycolor2}{rgb}{0.20000,0.62745,0.17255}
I Hot to improve it? \begin{tikzpicture}
I standalone class – \begin{axis}[%
minimalistic document, pdf % ... axis setting as before ...
only with the figure. ]
I Externalize – data are saved \addplot [color=mycolor1, line width=2.0pt]
table[]{mySinAndCos-1.tsv};
in extenal .tsv ASCI files,
\addlegendentry{data1}
matlab2tikz(’mySinAndCos.tex’,
’standalone’, true, \addplot [color=mycolor2, line width=2.0pt]
table[]{mySinAndCos-2.tsv};
’externalData’, true); \addlegendentry{data2}
\end{axis}
\end{tikzpicture}
\end{document}
sin x, cos x
I Load external data.
I Only files with data are changing. 0
Outline
1. Introduction
270
180 d W
150
L
120
90
1 2 3 4 5
electrical size ka
Comparison of two tracking methods4 .
4 M. Masek, M. Capek, L. Jelinek and K. Schab, “Modal Crossing Treatment Using Group Theory,” 2019
13th European Conference on Antennas and Propagation (EuCAP), Krakow, Poland, 2019.
Michal Mašek Graphics in LATEX 24 / 30
Drawing in Graphs
Drawing in Plots
Drawing in Plots
Drawing in Plots
Drawing in Plots
Drawing in Plots
sin x, cos x
\addplot [linesAll, markerCirc, PairedB]
table[x index=0,y index=1]{mySinAndCos.tsv}; 0
\addplot [linesAll, markerTria, PairedH]
table[x index=0,y index=2]{mySinAndCos.tsv};
\legend{$\sin x$, $\cos x$} −0.5
sin x, cos x
\tikzstyle{highlight} = [fill = red, fill 0
opacity = 0.3, inner sep = 0cm, circle, minimum
size = 0.5cm]
\node[highlight] (A) at (0.7854, 0.7071) {}; −0.5
\node[highlight] (B) at (3.9270, -0.7071) {}; crossing
−1
\node[red, fill = white] (C) at (1, -0.75) 0 1 2 3 4 5 6
{crossing}; x
z
y x
2 M. Masek, M. Capek, L. Jelinek, and K. Schab, “Modal Tracking Based on Group Theory,” submited to
5 M. Capek, “Source Concept and Its Utilization for the Analysis of Electrically Small
Antennas,” Habilitation lecture, Czech Technical University in Prague, Czech Republic, 2017.
Michal Mašek Graphics in LATEX 28 / 30
Source codes
Source codes
Cz2 270
l
sin x, cos x
180 d W
0
150
d L
ψ4 120 −0.5
ψ5 crossing
90
σvyz 1 2 3 4 5 −1
0 1 2 3 4 5 6
h electrical size ka x
6 Note that the code is not as perfect as possible. Sometimes a quick result was required instead of making
Questions?
Michal Mašek
michal.masek@fel.cvut.cz
Departmental seminars
May 7 and 14, 2019