TeX - LaTeX Asked on August 28, 2021
I needed to draw a graph on LaTex, I’m quite new to Tikz environment so I used the following code. My question is how to improve my code because I’m sure I can have a better result with fewer lines.
PS : is it possible to add a legend for s1 and z1 ?
documentclass[12pt,a4paper]{report}
usepackage[utf8]{inputenc}
usepackage[margin=1in]{geometry}
usepackage{graphicx}
usepackage{tikz}
usepackage{xcolor}
begin{document}
begin{center}
begin{tikzpicture}[thick, >=stealth]
%axe des x
draw [->] (-2.5,0) -- (1,0);
node at (1.5,0) {small textbf{Re(s)}};
%axe des y
draw [->] (0,-2.5) -- (0,2.5);
node at (0.5,2.6) {small textbf{Im(s)}};
%demi cerle
draw (0,1.5) arc (90:270:1.5cm);
%partie réelle omega n
draw [ultra thick] (-1.5,-0.1) -- (-1.5,0.1);
node at (-1.8,-0.2) {small textbf{$omega_n$}};
%moins alpha
draw [ultra thick] (-0.85,-0.1) -- (-0.85,0.1);
node at (-1.2,-0.2) {small textbf{-$alpha$}};
%dots
draw [dotted, thick] (0,-1.25) -- (-0.85,-1.25) -- (-0.85,1.25) -- (0,1.25);
%s1
node at (-0.85,1.25) {tiny textbf{+}};
node at (-1.1,1.3) {scriptsize textbf{$s_1$}};
%s2
node at (-0.85,-1.25) {tiny textbf{+}};
node at (-1.1,-1.3) {scriptsize textbf{$s_2$}};
% omega d
draw [very thick] (-0.1,1.25) -- (0.1,1.25);
node at (0.4,1.26) {scriptsize textbf{$omega_d$}};
%-omega d
draw [very thick] (-0.1,-1.25) -- (0.1,-1.25);
node at (0.4,-1.26) {scriptsize textbf{-$omega_d$}};
%segment
draw [thick] (-0.85,1.25) -- (0,0) -- (-0.85,-1.25);
%Phi
draw [ultra thin, ->] (-0.298,0.4) arc (140:90:0.4cm);
node at (-0.2,0.65) {scriptsize $phi$};
%zéro 1
draw (-.7,0.625) circle (0.7mm);
node at (-.7,0.4) {scriptsize $z_1$};
%zéro 2
draw (-.7,-0.625) circle (0.7mm);
node at (-.7,-0.4) {scriptsize $z_2$};
end{tikzpicture}
end{center}
end{document}
Maybe you'll like:
documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{angles, arrows.meta,
quotes}
begin{document}
begin{tikzpicture}[
> = Stealth,
every node/.append style = {font=small, text=black, fill=white, fill opacity=0.5,
text opacity=1, inner sep=1pt},
my angle/.style = {draw, thin, Straight Barb-Straight Barb,
angle radius=7mm, angle eccentricity=1.3,
font=small}
]
% axes x
draw[->] (-2.5,0) -- (1,0.0) node (x) [right] {$mathrm{Re}(s)$};
draw[->] (0,-2.5) -- (0,0) coordinate (O)
-- (0,2.5) node (y) [above] {$mathrm{Im}(s)$};
% semicircle
draw[thick, red] (0,1.5) arc (90:270:1.5);
% exis ticks
foreach i [count=x] in {-alpha, omega_n}
draw (-0.75*x,0.1) -- ++ (0,-0.2) node[below] {$i$};
% dashed line
draw[densely dashed, very thin, blue]
(0,-1.25) node[right] {$-omega_d$}
-- (-0.85,-1.25) node (s2) [label=left:$s_1$] {+}
-- (-0.85, 1.25) node (s1) [label=left:{$s_2=s_1^{*}$}] {+}
-- (0, 1.25) node[right] {$omega_d$};
% phasors
draw[thick, <->] (s1.center) -- (O) -- (s2.center);
% phase phi
pic [my angle, "$phi$"] {angle = y--O--s1};
% zéros
draw[semithick]
(-.7, 0.625) circle[radius=0.7mm] node[left=2pt] {$z_1$}
(-.7,-0.625) circle[radius=0.7mm] node[left=2pt] {$z_2$};
end{tikzpicture}
end{document}
(I focused only to image, so I select standalone
document class, however, you can instead it add preamble from your MWE.)
Correct answer by Zarko on August 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP