使用 tikz 绘制压力场

使用 tikz 绘制压力场

我想绘制一个沿高斯路径的压力场图形表示。我真的不知道该怎么做,但我的目标是画出一个像这样的图形(沿着整个路径):

在此处输入图片描述

我目前的编码如下:

\documentclass{article}


%%%%%%%%MATHS%%%%%%%%%%%%%
\usepackage{amsmath}

\DeclareMathOperator{\e}{e}


\usepackage{pgf, tikz, adjustbox}


%%%%%% PGFPLOTS %%%%%%%%%%%%
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\pgfmathdeclarefunction{gaussian}{2}
{%
    \pgfmathparse{(1/(#1 * sqrt(2 * pi))) * exp((-1 / 2) * (((x - #2)/#1) ^ 2))}%
}
\pgfmathsetmacro{\mean}{7}
\pgfmathsetmacro{\std}{0.3}

\usepgfplotslibrary{fillbetween}

\begin{document}

%%%%%%%%%%GAUSSIAN %%%%%%%%%%%%%%%%%%

\begin{figure}[h]   
\centering
\begin{tikzpicture}[dot/.style = {circle, fill, inner sep=1.0pt, node contents={}}]

\begin{axis}[
  no markers, domain=0:14, samples=200,
  axis lines=none, %axis lines*=left, 
  xlabel=$x$, ylabel=$y$,
  every axis y label/.style={at=(current axis.above origin),anchor=south},
  every axis x label/.style={at=(current axis.right of origin),anchor=west},
  height=5cm, width=17cm,
  xtick={\mean,12.5}, ytick=\empty,
  enlargelimits=false, clip=false, axis on top,
  grid = major
  ]
  

% HERE IS THE SECTION USED TO DRAW THE PATH OF THE GAUSSIAN
  \addplot [fill=cyan!20, draw=none, domain=0:14] {gaussian(1.5+\std,\mean)} \closedcycle;
  \addplot [name path=haute,very thick,cyan!50!black] {gaussian(1.5+\std, \mean)+0.05};
  \addplot [name path=basse,very thick,cyan!50!black] {gaussian(1.5+\std, \mean)};
  \addplot [very thick,cyan!50!black] {gaussian(1.5+\std, \mean)+0.05}--(14,0); % ligne entre fin de la fonction et axe des abscisses
  

 % On remplit la zone entre les 2 courbes
  \addplot fill between[
    of = haute and basse,
    soft clip={domain=0:14},
    every even segment/.style  = {pink,opacity=.2}
  ];

% On crée une ligne artificielle pour fermer le contour à gauche
\draw[very thick, cyan!50!black]  (0,0) -- (0,0.05011524462);

% On crée les indications pour les quantités H(x,t) et R(x,t)
\draw[dashed,red, stealth-stealth, very thick] (8,0) -- node[fill=cyan!20,scale=0.75] {$h(x,t)$} (8,0.189940);
\draw[dashed,red, stealth-stealth, thick] (7,0.025) -- node[fill=cyan!20,scale=0.75] {$R(x,t)$} (12.5,0.025);

% On remplit la zone intermédiaire entre les 2 rectangles gris (SANS CONTOURS)
\path[fill=cyan!20] (6.5,-0.2) -- (6.5,0) -- (7.5,0) -- (7.5,-0.2) -- (6.5,-0.2);


% On crée le label sur le flux Q(x,t)
\draw [yshift=-0.6cm, -stealth](7,-0.1) -- node [fill=cyan!20] {$Q(t)$} (7,0);
\node[right] at (5.5,0.1) {$(\rho,\mu)$};


% Construction des axes
\draw[dotted,-stealth,thick] (7, 0) -- (15,  0) node[right] {$\underline{e}_x$}; % x-axis
\draw[dotted,-stealth,thick] (7, 0) -- ( 7,0.325) node[above] {$\underline{e}_z$}; % y-axis
\path (7,0) node[black,dot,label=below left:$0$];

\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}

有没有简单的方法可以做到这一点?提前谢谢您。

答案1

对我来说重新开始更容易——你实际上并没有使用 PGFPlots 做任何事情,你也不需要fillbetween

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.markings, arrows.meta}
\begin{document}
\begin{tikzpicture}[
declare function={
gauss(\x)=3*exp(-(\x/3)^2);
}]
\fill[cyan!20] plot[domain=-8:8, samples=100] (\x, {gauss(\x)});
\filldraw[fill=pink!20, very thick] plot[domain=-8:8, samples=100] (\x, {gauss(\x)}) -- plot[domain=8:-8, samples=100] (\x, {gauss(\x)+0.6}) -- cycle;
\path[
decoration={
  markings,
  mark=between positions 0 and 1 step 1/10 with {\draw[ultra thick, -{Triangle}] (0,1.2) -- (0,0.1);}},
decorate,
] plot[domain=-8:8, samples=100] (\x, {gauss(\x)+0.6});
\fill (0,0) circle[radius=2pt];
\draw[dotted, thick, -Stealth] (0,3) -- (0,0) -- (9,0);
\draw[red, dashed, thick, Stealth-Stealth] (1,0) --node[fill=cyan!20]{$h(x,t)$} (1,{gauss(1)});
\end{tikzpicture}
\end{document}

实心高斯曲线和垂直箭头

相关内容