对我的代码的评论

对我的代码的评论

我开始使用 TiKz 来创建图形,我希望一些更高级的用户对我的代码提出意见。从提示到建议,或者可以用不同且更好的方式完成的事情,我都会很感激。
这是我的代码:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage{tikz, pgfplots}
\usepackage[european]{circuitikz}
\usepackage{float}

\pgfplotsset{compat=1.12}
\usetikzlibrary{calc}



\newcommand{\subb}[1]{_{\mathrm{#1}}}

\begin{document}

    \begin{figure}[H]
        \centering
        \begin{circuitikz}
            \draw
            (0,0) to[battery,l_=$V\subb{in}$] ++(0,-4) coordinate (v)
    %       (0,0) to[short]++(1,0)
            (0,0) to[inductor, l^=$L$,-*,v_=$v\subb L$,i=$i\subb L$] ++(3,0) coordinate (s1)
            ([xshift=15pt, yshift=-15pt]s1) coordinate (son) 
            (son) to[short,o-] (son|-v)
            to[short] (v)
            ([xshift=22pt]s1) coordinate (soff)
            (soff) to[short,o-*]++(2,0) coordinate (c)
            to[C,l_=$C$,i>_=$i\subb C$]  (c|-v) coordinate (cc)
            to[short,*-*] (cc-|son)
            (c) to[short] ++ (2,0) coordinate (l)
            to[R,l_=$R\subb L$,v^=$V\subb{out}$,i>_=$i\subb{out}$] (l|-cc)
            to[short] (cc);
            \draw [very thick] (s1)--++(19pt,-8pt);
            \node[anchor = north east] at (son) {$T\subb{ON}$};
            \node[anchor = south] at (soff) {$T\subb{OFF}$};
        \end{circuitikz}
        \caption{Boost converter}
        \label{circ:boost_diagrama}
    \end{figure}
    \begin{figure}[H]
        \centering
        \begin{tikzpicture}
        \def\ton{1}
        \def\toff{2}
        \def\von{2}
        \def\voff{-3}
        \def\ilmax{3}
        \def\ilmin{1.4}

        \begin{axis}
        [
            xlabel = $t$,
            axis x line=center,
            axis y line=center,
            x label style = {anchor=north},
            y label style = {anchor=east},
            no markers,
            xmin = -0.3, xmax = \toff + 0.7,
            ymin = \voff - 0.5, ymax = \von + 2,
            xtick = {0,\ton,\toff},
            xticklabels = {0,{$T\subb{ON}$},{$T\subb{OFF}$}},
            x tick label style = {anchor=north east},
            ytick = {\von,\voff,\ilmax,\ilmin},
            yticklabels = {{\color{blue}$V\subb{in}$},{\color{blue}$V\subb{in}-V\subb{out}$},{\color{red}$I\subb{L\subb{max}}$},{\color{red}$I\subb{L\subb{max}}$}}
        ]
            \addplot [blue, thick] coordinates 
            {
                (0,\von)
                (\ton,\von)
                (\ton,\voff)
                (\toff,\voff)
                (\toff,\von)
                (\toff+0.5,\von)
            };
            \draw [dashed] (axis cs:\ton, \voff) -- (axis cs:0, \voff);
            \addplot [red, thick] coordinates 
            {
                (0,\ilmin)
                (\ton,\ilmax)
                (\toff,\ilmin)
                (\toff+0.5,{\ilmin+(\ilmax-\ilmin)*0.5})
            };
            \draw [dashed] (axis cs:\ton,\ilmax) -- (axis cs:0, \ilmax);
            \draw [dashed] (axis cs:\toff,\ilmin) -- (axis cs:0, \ilmin);
            \legend{$v\subb L$,$i\subb L$}
        \end{axis}
        \end{tikzpicture}
        \caption{Voltage and current in across the inductor}
        \label{graf:tensio_corrent_L}
    \end{figure}
\end{document}

我的结果是: 在此处输入图片描述

正如您所看到的,解决方案看起来不错,但我希望收到一些有关我的代码的评论。

谢谢!

相关内容