如何在 latex 或 tikz 中进行粒子置换?

如何在 latex 或 tikz 中进行粒子置换?

大家好,我目前不知道如何进行压缩和稀疏粒子位移。图像的顶部应该没问题,我已经在 tikz 中完成了,但我想使用 tikz 绘制底部粒子位移部分(或者是否有任何其他为此制作的软件包),但我不知道该怎么做。任何帮助都将不胜感激。在此处输入图片描述

答案1

以下是基于的提议这个答案

\documentclass[border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta}
\begin{document}
    \begin{tikzpicture}[font=\sffamily]
        \begin{axis}[width=12cm,height=5cm,
            hide axis,
        ]
            \addplot [
                only marks,
                domain=0:6*pi,
                samples=1200,
                mark size=0.75,
            ] (
                {sin(deg(x+0.3*rand)) + x+0.3*rand},
                {rand}
            );
          \coordinate (max1) at ({pi},0);   
          \coordinate (max2) at ({3*pi},0);
          \coordinate (max3) at ({5*pi},0);
          \coordinate (min2) at ({2*pi},0); 
          \coordinate (min3) at ({4*pi},0); 
        \end{axis}
        \node (comp) at ([yshift=-1cm]min2 |- current axis.south) {compressions};
        \draw[-latex] (comp) -- (max1 |- current axis.south);
        \draw[-latex] (comp) -- (max2 |- current axis.south);
        \node (rare) at ([yshift=1cm]max2 |- current axis.north) {rarefactions};
        \draw[-latex] (rare) -- (min2 |- current axis.north);
        \draw[-latex] (rare) -- (min3 |- current axis.north);
        \draw[{Straight Barb[length=0pt,width=4mm] Latex[]}-{Latex[] Straight Barb[length=0pt,width=4mm]}] 
        ([yshift=-0.3cm]max2 |- current axis.south)
        --([yshift=-0.3cm]max3 |- current axis.south) 
        node[midway,fill=white]{$\lambda$};
        \draw[-latex] ([yshift=0.3cm]max3 |- current axis.north)
        -- ([yshift=0.3cm]current axis.north east)
        node[midway,above,align=center]{direction of\\ wave motion};
        \draw[latex-latex] ([xshift=0.2cm,yshift=-0.3cm]max3 |- current axis.south)
        -- ([yshift=-0.3cm]current axis.south east)
        node[midway,below,align=center]{direction of\\ particle motion};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:纯 TiZ 解决方案可以更好地控制局部密度。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\pgfmathsetseed{12}
\begin{tikzpicture}[font=\sffamily]
\foreach \Z in {1,...,1234}
{
 \pgfmathsetmacro{\X}{3*pi*(0.5*rand+0.5)}
 \pgfmathsetmacro{\Y}{rand}
 \pgfmathtruncatemacro{\V}{ifthenelse(1.1+0.8*sin(deg(2*\X))>1+rand,1,0)}
 \ifnum\V=1
    \fill (\X,\Y) circle (1pt);
 \fi    
}
\node[minimum width=1.5*pi*1cm,minimum height=2cm]at (3*pi,0)(current axis){};
\coordinate (max1) at ({pi/4},0);   
\coordinate (max2) at ({5*pi/4},0);
\coordinate (max3) at ({9*pi/4},0);
\coordinate (min2) at ({3*pi/4},0); 
\coordinate (min3) at ({7*pi/4},0);
\node (comp) at ([yshift=-1cm]min2 |- current axis.south) {compressions};
\draw[-latex] (comp) -- (max1 |- current axis.south);
\draw[-latex] (comp) -- (max2 |- current axis.south);
\node (rare) at ([yshift=1cm]max2 |- current axis.north) {rarefactions};
\draw[-latex] (rare) -- (min2 |- current axis.north);
\draw[-latex] (rare) -- (min3 |- current axis.north);
\draw[{Straight Barb[length=0pt,width=4mm] Latex[]}-{Latex[] Straight Barb[length=0pt,width=4mm]}] 
([yshift=-0.3cm]max2 |- current axis.south)
--([yshift=-0.3cm]max3 |- current axis.south) 
node[midway,fill=white]{$\lambda$};
\draw[-latex] ([yshift=0.3cm]max3 |- current axis.north)
-- ([yshift=0.3cm]current axis.north east)
node[midway,above,align=center]{direction of\\ wave motion};
\draw[latex-latex] ([xshift=0.2cm,yshift=-0.3cm]max3 |- current axis.south)
-- ([yshift=-0.3cm]current axis.south east)
node[midway,below,align=center]{direction of\\ particle motion};    
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容