改进 Tikz 代码

改进 Tikz 代码

我需要在 LaTex 上绘制图表,我对 Tikz 环境还不熟悉,所以我使用了以下代码。我的问题是如何改进我的代码,因为我确信用更少的行可以得到更好的结果。PS:是否可以为 s1 和 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}

在此处输入图片描述

答案1

也许你会喜欢:

\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}

(我只关注图像,因此我选择standalone文档类,但是,您也可以从 MWE 中添加前言。)

在此处输入图片描述

相关内容