Tikz 绘制平滑线条

Tikz 绘制平滑线条

我怎样才能重现上图红圈内的线条? 在此处输入图片描述

我的代码是:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns, arrows,shapes,positioning,shadows,trees, decorations.text,arrows.meta, decorations.pathmorphing, pgfplots.fillbetween, quotes, patterns.meta,shapes.geometric, decorations.markings, calc}

\begin{document}


    \begin{tikzpicture}
        \draw[-latex,ultra thick] (-4,0)--(5,0);
        \draw[thick, dashed] (0,-4)--(0,4);
        \draw[thick, dashed] (4,-4)--(4,4);
        \draw[-latex,ultra thick] (-4,-4)--(-4,4);
        \draw[latex-latex,ultra thick] (0,3.5)--(4,3.5);
        \draw[latex-latex,ultra thick] (0,-3.5)--(-4,-3.5);    
        \node[font=\sffamily] at (2,3.8) {Generator mode};
        \node[font=\sffamily] at (-2,-3.8) {Motor mode};
        \node[] at (4.8,0.5) {Slip};
        \node[] at (-3.75,-0.3) {$1$};
        \node[] at (0.25,-0.3) {$0$};
        \node[] at (4.3,-0.3) {$-1$};
        \node[rotate = 90] at (-4.5,0) {Torque [N.m]};
        \draw[smooth, red, ultra thick] (-4,3) -- (-1.5,2.75) -- (0,2.5);
        \draw[smooth, green, ultra thick] (0,2.5) -- (0,-2.5);
        \draw[smooth, red, ultra thick] (0,-2.5) -- (1.5,-2.75) -- (4,-3);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

谢谢!

答案1

您可以尝试替换这个:

\draw[smooth, red, ultra thick] (-4,3) -- (-1.5,2.75) -- (0,2.5);

有了这个:

\draw[smooth, red, ultra thick] plot coordinates {(-4,3) (-1.5,2.75) (0,2.5)};

您还可以对张力参数进行更多的控制:

\draw[smooth, tension=1, red, ultra thick] plot coordinates {(-4,3) (-1.5,2.75) (0,2.5)};

你可以试一下,看看哪种适合你(0 会产生像以前一样的清晰线条)

唯一的问题是,不同线路之间没有很好的过渡

编辑:我刚刚找到了一个更好的解决方案:

\draw[red,ultra thick,looseness=0.3] (-4,3) to[out=0, in=90] (0,2.5);
\draw[red,ultra thick,looseness=0.3] (0,-2.5) to[out=-90,in=180] (4,-3);

这个可以更好地过渡到绿线,而且您不必提供辅助点。in 和 out 参数控制曲线的进入和退出角度。looseness 选项与上一个解决方案中的tension 参数具有相同的效果。

答案2

这是您要找的东西吗?

虚线椭圆

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{patterns, arrows,shapes,positioning,shadows,trees, decorations.text,arrows.meta, decorations.pathmorphing, quotes, patterns.meta,shapes.geometric, decorations.markings, calc}

\begin{document}


    \begin{tikzpicture}
        \draw[-latex,ultra thick] (-4,0)--(5,0);
        \draw[thick, dashed] (0,-4)--(0,4);
        \draw[thick, dashed] (4,-4)--(4,4);
        \draw[-latex,ultra thick] (-4,-4)--(-4,4);
        \draw[latex-latex,ultra thick] (0,3.5)--(4,3.5);
        \draw[latex-latex,ultra thick] (0,-3.5)--(-4,-3.5);    
        \node[font=\sffamily] at (2,3.8) {Generator mode};
        \node[font=\sffamily] at (-2,-3.8) {Motor mode};
        \node[] at (4.8,0.5) {Slip};
        \node[] at (-3.75,-0.3) {$1$};
        \node[] at (0.25,-0.3) {$0$};
        \node[] at (4.3,-0.3) {$-1$};
        \node[rotate = 90] at (-4.5,0) {Torque [N.m]};
        \draw[smooth, red, ultra thick] (-4,3) -- (-1.5,2.75) -- (0,2.5);
        \draw[smooth, green, ultra thick] (0,2.5) -- (0,-2.5);
        \draw[smooth, red, ultra thick] (0,-2.5) -- (1.5,-2.75) -- (4,-3);
        
        \draw[densely dashed] (-2,2.8) ellipse (1.9cm and .3cm);
        \draw[densely dashed] (0,0) ellipse (0.2cm and 3cm);
        \draw[densely dashed] (2,-2.8) ellipse (1.9cm and .3cm);
    \end{tikzpicture}
\end{document}

相关内容