我怎样才能在 LaTex 中绘制这幅图?

我怎样才能在 LaTex 中绘制这幅图?

在此处输入图片描述

我已尝试过这种方法,但没有得到正确的结果。

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
%\usetikzlibrary{hobby}
%\usetikzlibrary{decorations.pathmorphing}

\begin{document}

\begin{tikzpicture}

\draw  plot[smooth, tension=.4] coordinates {(-2.5,-0.5) (-3.5,0) (-2.5,0.5) (-3.5,1) (-2.5,1) (-3.5,1.5) (-2.5,1.8) (-3.5,2.5) (-2.5,3) (-3.5,3.5) (-2.5,4)};
\draw [thick](-2.5,0.5)--(0.5,0.5)--(0.5,3)--(-2.5,3);
\draw (-2.5,-0.5) -- (3,-0.5) -- (3,4) -- (-2.5,4);

\end{tikzpicture}

%\begin{tikzpicture}
%\draw (1,1) circle (1cm);
%\draw[thick,->] (2,2) -- (1,1);
%\draw(2.5,2.2) node{center};
%\end{tikzpicture}

\end{document}

答案1

这幅图的主要问题是线条不平整。可以使用decorations.pathreplacingtikz 库绘制,或者像下面的代码一样用随机点绘制曲线。我认为其余部分非常简单。

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{babel} % because sometimes tikz and some babel packages don't get along

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
  % dimensions
  \def\lb{2.5} % little rectangle base
  \def\lh{1}   % little rectangle semi-height
  \def\bb{6}   % big rectangle base
  \def\bh{3}   % big ractangle semi-height
  % coordinates
  \coordinate (O)   at (0,0);
  \coordinate (Ar1) at (\lb+1,-0.5*\lh-0.5*\bh);
  \coordinate (Ar2) at (\lb+1,0);
  \coordinate (Ar3) at (\lb+1, 0.5*\lh+0.5*\bh);
  % rectangles
  \draw (0,-\lh) -| (\lb,\lh) -- (0,\lh);
  \draw (0,-\bh) -| (\bb,\bh) -- (0,\bh);
  % points
  \draw[dotted] (\lb,-\lh) to[bend left]  (Ar1);
  \draw[dotted] (\lb, \lh) to[bend right] (Ar3);
  \fill (Ar1) circle (1pt) node [right] {$\underline{A}_r$};
  \fill (Ar2) circle (1pt) node [right] {$A_r$};
  \fill (Ar3) circle (1pt) node [right] {$\overline{A}_r$};
  \fill (O)   circle (1pt) node [below left] {$(0,0)$};
  % ragged lines
  \pgfmathsetseed{3} % this fixes the random points to be always the same
  \draw        plot[domain=-\bh:-\lh,samples=6,smooth] ({-0.25*(rand+1)*(\bh+\x)*(\lh+\x)},\x);
  \draw[thick] plot[domain=-\lh:0   ,samples=6,smooth] ({-(rand+1)*\x*(\lh+\x)},\x);
  \draw[thick] plot[domain=0:\lh    ,samples=6,smooth] ({(rand+1)*\x*(\lh-\x)},\x);
  \draw        plot[domain=\lh:\bh  ,samples=6,smooth] ({-0.25*(rand+1)*(\bh-\x)*(\lh-\x)},\x);
  % labels
  \node (xn) at (-2,\bh)               {$x_n=f(x',t)$};
  \node (dr) at (-2,0.5*\lh)           {$\Delta r$};
  \node      at (0.75,0.5)             {$\Psi_r$};
  \node      at (\bb,\bh) [below left] {$D$};
  \draw[-latex] (xn.south) to [bend right] ++ (2,-0.5);
  \draw[-latex] (dr.north) to [bend left]  ++ (2,0);
  \def\sep{0.1} % arrow lines separation
  \draw[red,<->] (\lb-\sep,-\lh+\sep) -- (\lb-\sep,\lh-\sep)  node [midway,left]  {$2r^2$};
  \draw[red,<->] (\sep,-\lh-\sep)     -- (\lb-\sep,-\lh-\sep) node [midway,below] {$\sim r$};
  % axes
  \begin{scope}[shift={(\bb+3,\bh-1)}]
    \draw[-latex] (0,0) -- ( 1  , 0  ) node [right]      {$x_n$};
    \draw[-latex] (0,0) -- ( 0  , 1  ) node [above]      {$t$};
    \draw[-latex] (0,0) -- (-0.7,-0.7) node [below left] {$x'$};
  \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容