如何使用 tikz 绘制此图像?

如何使用 tikz 绘制此图像?

在此处输入图片描述

除了这个特定图表的解决方案之外,你还能解释一下如果有获取此代码需要遵循哪些常规步骤?

我的猜测:转换为矢量图形是否会提供一些指导?

流程中有哪些部分可以实现自动化?等等。

我试过:使用 Inkscape 转换为矢量图形并以某种方式获取一堆坐标,我可以将其用作 tikz 代码的指南。

到目前为止我得到了以下信息(我从中获取了一些代码这个答案):

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}

\pgfmathdeclarefunction{gauss}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}%
}

\begin{document}‎‎

\begin{tikzpicture}
\draw[draw=none](0,4)--node[anchor=center, above] (A) {Marginal
distribution of Brownian motion through time} (10,4) ;
\draw[->,very thick](0,0)--(0,4) node[anchor=south, above left,
rotate=90] {Spacial distribution};
\draw[->,very thick](0,0)-- node[anchor=north, below] {Time} (10,0);
\draw[dotted, domain=0:9,samples=35,thick] plot ({\x+0.5},
{sqrt(\x)/2+2});
\draw[dotted, domain=0:9,samples=35, thick, smooth, postaction=
{decorate, decoration={raise=-10pt, text along path,text 
align=center,text={Spread of Willow Tree}}}] plot ({\x+0.5},
{-sqrt(\x)/2+2});
\draw[very thin, domain=-0.5:2.5,samples=35] plot({gauss(\x, 1, 1)+1},
{\x+1}) node (B) {};
\draw[very thin, domain=-0.5:2.5,samples=35] plot({gauss(\x, 1, 0.5)+3},
{\x+1}) node (C) {};
\draw[very thin, domain=-0.5:2.5,samples=35] plot({gauss(\x, 1, 0.25)+5},
{\x+1}) node (D) {};
\draw[very thin, domain=-0.5:2.5,samples=35] plot({gauss(\x, 1, 0.2)+7},
{\x+1}) node (E) {};
\draw[->] (A) to (B);
\draw[->] (A) to (C);
\draw[->] (A) to (D);
\draw[->] (A) to (E);
\end{tikzpicture}

\end{document}

生成结果:

在此处输入图片描述

答案1

应该为您指明正确的方向......

\documentclass[tikz, border=5]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth, line cap=round]
\draw [thick, ->] (0,-2) -- (0, 2)
  node [midway, sloped, above] {Spatial distribution};
\draw [thick, ->] (0,-2) -- (10,-2)
  node [midway, below] {Time};
\draw [thick, dotted] 
  plot [domain=-1.5:1.5, samples=50] ({(\x*2)^2+.5},\x)
  node [right, align=center] {Spread of \\ willow tree};
\foreach \t [count=\i] in {.1,0.5,1,1.5}
  \draw plot [domain=-3:3, samples=20, smooth]
    ({\i*2 + sqrt(0.5*\t*pi)*exp(-0.5*\t*pow(\x,2))}, \x/2)
    coordinate (distribution-\i);
\node [above] (label) at (5,2) 
  {Marginal distribution of Brownian motion through time};
\foreach \i in {1,...,4}
  \draw [->, shorten >=1ex] (label) -- (distribution-\i);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

以下是一种pgfplots方法:

pgf图

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

\pgfmathdeclarefunction{gauss}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}%
}

\begin{document}

\begin{tikzpicture}
  \begin{scope}[rotate=-90]

  \begin{axis}[
    domain=-0.5:2.5,
    xmin=-1, xmax=3,
    ymin=0, ymax=10,
    xlabel=Spacial distribution, ylabel=Time,
    xtick=\empty, ytick=\empty,
    axis x line=bottom, axis y line=right,
    x axis line style = {very thick,stealth-},
    y axis line style = {very thick},
    height=\textwidth,
    width=.5\textwidth,
    clip=false]

    \addplot[mark=none, thick, dotted,
      postaction={decorate, decoration={raise=-10pt, text along path,
        text align={right, right indent=3.5cm},text={|\scriptsize|Spread of Willow Tree}}}]
      {((x-1)*2)^2+.5};

    \node [xshift=-1cm,rotate=90] (label) at (current bounding box.west) 
      {Marginal distribution of Brownian motion through time};

    \foreach \t/\i in {1/1, 0.5/3, 0.25/5, 0.2/7} {
      \addplot[samples=35,smooth] {gauss(x, 1, \t)+\i};          
      \edef\temp{
        \noexpand\coordinate (g-\i) at (axis cs:-0.5,\i);
        \noexpand\draw [->, shorten >=2ex] (label) -- (g-\i);}
      \temp
    }
  \end{axis}
  \end{scope}

\end{tikzpicture}

\end{document}

相关内容