图表帮助

图表帮助

在此处输入图片描述

我试过了,但是没成功。你需要在图片上重复绘图,还要添加文本(你可以自己添加,我会编辑)。 在此处输入图片描述 我的代码:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}

\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        axis lines=middle,
        axis line style={->},
        xlabel={},
        ylabel={},
        xtick={1, 2, 3},
        ytick=\empty,
        ymin=-2, ymax=2,
        xmin=0, xmax=3.5,
        every axis x label/.style={at={(axis description cs:1,0.5)},anchor=west},
        every axis y label/.style={at={(axis description cs:0.5,1)},anchor=south},
        no marks,
        clip=false,
        xticklabels={,,},
        yticklabels={,,},
        tick style={draw=none}
    ]

    % Sine wave, black
    \addplot+[domain=0:3, samples=200, smooth, black, thick] {sin(deg(2*pi*x))};
    % Cosine wave, green
    \addplot+[domain=0:3, samples=200, smooth, green!70!black, thick] {cos(deg(2*pi*x))};

    % Red vertical line
    \draw [red, thick] (axis cs:0,-2) -- (axis cs:0,2);
    % Gray horizontal line
    \draw [gray, thick] (axis cs:0,0) -- (axis cs:3.5,0);

    % Labels
    \node at (axis cs:1,0) [anchor=north] {1};
    \node at (axis cs:2,0) [anchor=north] {2};
    \node at (axis cs:3,0) [anchor=north] {3};

    \end{axis}
\end{tikzpicture}
\end{document}

答案1

仅供参考,这里有一种方法可以做到这一点。备注:

  • 在我看来,您要做的事情就像傅里叶合成。因此,只需添加两个函数的输出即可。
  • 为了简单起见,我只是复制了你的方程式。当然有办法将它们作为函数。
  • 您的周期/频率/波长不合理。这就是结果(虚线,蓝色)不同的原因。调整振幅和波长,您就会得到想要的结果。

结果

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}

\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        axis lines=middle,
        axis line style={->},
        xlabel={},
        ylabel={},
        xtick={1, 2, 3},
        ytick=\empty,
        ymin=-2, ymax=2,
        xmin=0, xmax=3.5,
        every axis x label/.style={at={(axis description cs:1,0.5)},anchor=west},
        every axis y label/.style={at={(axis description cs:0.5,1)},anchor=south},
        no marks,
        clip=false,
        xticklabels={,,},
        yticklabels={,,},
        tick style={draw=none}
    ]

    % Sine wave, black
    % changed amplitude
    \addplot+[domain=-1:3, samples=200, smooth, black, thick] {.333*cos(deg(2*pi*x))};
    % Cosine wave, green
    % changed frequency
    \addplot+[domain=-1:3, samples=200, smooth, green!70!black, thick] {cos(deg(2*pi*2/3*x))};
    % ~~~ sum of both ~~~~
   \addplot+[domain=-1:3, samples=200, smooth, blue, thick, dashed] {.333*cos(deg(2*pi*x)) + cos(deg(2*pi*2/3*x))};
   
   
    % Red vertical line
    \draw [red, thick] (axis cs:0,-2) -- (axis cs:0,2);
    % Gray horizontal line
    \draw [gray, thick] (axis cs:-1,0) -- (axis cs:3.5,0);

    % Labels
    \node at (axis cs:1,0) [anchor=north] {1};
    \node at (axis cs:2,0) [anchor=north] {2};
    \node at (axis cs:3,0) [anchor=north] {3};

    \end{axis}
\end{tikzpicture}
\end{document}

附言

这是一种 TeX 式的方法,当然不推荐。

在开始时定义宏,因此只需在这里更改值:

...
\def\fa{.333*cos(deg(2*pi*x))}
\def\fb{1*cos(deg(2*pi*2/3*x))}
\def\fc{\fa + \fb}

\begin{document}
...

用宏替换你的公式:

    % Sine wave, black
    % changed amplitude
    \addplot+[domain=-1:3, samples=200, smooth, black, thick] {\fa};
    % Cosine wave, green
    % changed frequency
    \addplot+[domain=-1:3, samples=200, smooth, green!70!black, thick] {\fb};
    % ~~~ sum of both ~~~~
   \addplot+[domain=-1:3, samples=200, smooth, blue, thick, dashed] {\fc};

公共服务计划

这是参数的选择,更接近您原始的(现已丢失的)屏幕截图:

\def\fa{.333*cos(deg(2*pi*x*5/8))}
\def\fb{1*cos(deg(2*pi*1*x/4))}
\def\fc{\fa + \fb}

结果2

相关内容