翻转版本

翻转版本

我正在尝试重新创建电磁波谱的图像:

电磁频谱

我想绘制一个如图所示的频率变化的正弦/余弦波。

到目前为止,我一直在做一些非常棘手的事情,但这并不理想,因为我无法在不手动更改所有数字的情况下更改波形。有人能建议一个更优雅的解决方案吗?也许可以使用单个正弦/余弦函数?

\begin{tikzpicture}
\draw (0,0) -- (12,0);
\draw (0.2,1)node[left,font=\tiny] {$y=1$} -- (11.8,1);
\draw (0.2,-1)node[left,font=\tiny] {$y=-1$} -- (11.8,-1); 
\foreach \x in {0,0.5,...,12}{
\draw (\x,-0.2)node [below,font=\tiny,] {\x} -- (\x,0.2) ;
}
\draw[ultra thick, red] (0,0) sin (1,1);    %% the real business in this line
\draw[ultra thick, red] (1,1) cos (2.0,0);    %% the real business in this line
\draw[ultra thick, red] (2.0,0) sin (3,-1);    %% the real business in this line
\draw[ultra thick, red] (3,-1) cos (3.9,0);    %% the real business in this line
\draw[ultra thick, red] (3.9,0)  sin (4.8,1);    %% the real business in this line
\draw[ultra thick, red] (4.8,1) cos (5.6,0);    %% the real business in this line
\draw[ultra thick, red] (5.6,0) sin (6.4,-1);    %% the real business in this line
\draw[ultra thick, red] (6.4,-1) cos (7.2,0);    

 \draw[ultra thick, red] (7.2,0)  sin (7.9,1);    %% the real business in this line
\draw[ultra thick, red] (7.9,1) cos (8.55,0);    %% the real business in this line
\draw[ultra thick, red] (8.55,0) sin (9.2,-1);    %% the real business in this line
\draw[ultra thick, red] (9.2,-1) cos (9.7,0.0);

     \draw[ultra thick, red] (9.7,0)  sin (10.2,1);    %% the real business in this line
\draw[ultra thick, red] (10.2,1) cos (10.6,0);    %% the real business in this line
\draw[ultra thick, red] (10.6,0) sin (11.0,-1);    %% the real business in this line
\draw[ultra thick, red] (11.0,-1) cos (11.3,0); %% the real business in this line 

         \draw[ultra thick, red] (11.3,0)  sin (11.6,1);    %% the real business in this line
\draw[ultra thick, red] (11.6,1) cos (11.8,0);    %% the real business in this line
\draw[ultra thick, red] (11.8,0) sin (12.0,-1);    %% the real business in this line
\draw[ultra thick, red] (12.0,-1) cos (12.2,0); %% the real business in this line 

             \draw[ultra thick, red] (12.2,0)  sin (12.4,1);    %% the real business in this line
\draw[ultra thick, red] (12.4,1) cos (12.55,0);    %% the real business in this line
\draw[ultra thick, red] (12.55,0) sin (12.7,-1);    %% the real business in this line
\draw[ultra thick, red] (12.7,-1) cos (12.85,0); %% the real business in this line 

                 \draw[ultra thick, red] (12.85,0)  sin (13.0,1);    %% the real business in this line
\draw[ultra thick, red] (13.0,1) cos (13.1,0);    %% the real business in this line
\draw[ultra thick, red] (13.1,0) sin (13.2,-1);    %% the real business in this line
\draw[ultra thick, red] (13.2,-1) cos (13.3,0); %% the real business in this line 

 \draw[ultra thick, red] (13.3,0)  sin (13.4,1);    %% the real business in this line
\draw[ultra thick, red] (13.4,1) cos (13.48,0);    %% the real business in this line
\draw[ultra thick, red] (13.48,0) sin (13.56,-1);    %% the real business in this line
\draw[ultra thick, red] (13.56,-1) cos (13.62,0); %% the real business in this line 

     \draw[ultra thick, red] (13.62,0)  sin (13.69,1);    %% the real business in this line
\draw[ultra thick, red] (13.69,1) cos (13.76,0);    %% the real business in this line
\draw[ultra thick, red] (13.76,0) sin (13.82,-1);    %% the real business in this line
\draw[ultra thick, red] (13.82,-1) cos (13.88,0); %% the real business in this line 
\draw[ultra thick, red] (13.88,0)  sin (13.92,1);    %% the real business in this line
\end{tikzpicture}

当前尝试

答案1

带有蓝移。

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis,red,width=16cm,height=4cm,thick] 
\addplot[domain=20:300,samples=800,        
colormap={}{ % Define the colormap from https://tex.stackexchange.com/questions/243689/create-a-plot-line-with-a-gradient
            color(2cm)=(red);
            color(16cm)=(blue);
        },
        ultra thick, point meta=x*x,mesh]{sin(pow(x,2)/15)};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

sin(deg((\fmin+\x*((\fmax-\fmin))/\xmax)*\x))如果频率增加是线性的,则频率增加的正弦波具有表达式,sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))如果频率增加是指数的,则频率增加的表达式。我已经看到指数增加似乎提供更好的结果。在下面的代码中,将 设置\xmax为 的最大值x\fmin设置为 的最小频率,\fmax设置为 的最大频率。注释行使用线性频率增加,未注释行使用指数频率增加。

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
    \newcommand{\xmax}{14}
    \newcommand{\fmin}{(pi/3)}
    \newcommand{\fmax}{(2*pi)}
\begin{tikzpicture}[domain=0:\xmax, samples=500]
\draw (0,0) -- (12,0);
\draw (0.2,1)node[left,font=\tiny] {$y=1$} -- (11.8,1);
\draw (0.2,-1)node[left,font=\tiny] {$y=-1$} -- (11.8,-1); 
\foreach \x in {0,0.5,...,12}{
    \draw (\x,-0.2)node [below,font=\tiny,] {\x} -- (\x,0.2) ;
}

% The following line uses linear frequency increase
%\draw[ultra thick, red] plot (\x, {sin(deg((\fmin+\x*((\fmax-\fmin))/\xmax)*\x))} );
% The following line uses exponential frequency increase
\draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

PSTricks 解决方案仅用于比较目的。

\documentclass[pstricks]{standalone}
\usepackage{pst-plot,pst-calculate}
\begin{document}
\begin{pspicture}[algebraic](0,-1.5)(\pscalculate{2*pi},1.5)
    \psplot[plotpoints=3000]{0}{2 Pi mul}{sin(x^3/2)}
\end{pspicture}
\end{document}

在此处输入图片描述

翻转版本

\documentclass[pstricks]{standalone}
\usepackage{pst-plot,pst-calculate}
\begin{document}
\begin{pspicture}[algebraic](0,-1.5)(\pscalculate{2*pi},1.5)
    \psplot[plotpoints=3000]{0}{2 Pi mul}{sin((x-TwoPi)^3/2)}
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容