是否可以用 Latex 绘制正常域?

是否可以用 Latex 绘制正常域?

我正在尝试绘制这种图像,它是相对于 x 轴的法向域的表示,但我对 LaTeX 不是很熟练。有谁知道怎么做吗?

在此处输入图片描述

答案1

这当然不是最优雅的解决方案,但也许可以作为一个起点。

我以此pgfplots为基础绘制了坐标系以及“正常域”。所有内容都绘制在一个axis块内。顶部和底部的边界线是使用tikzlibrarycurve through中的插值功能创建的hobby。因此,我定义了坐标 (A) 到 (F)(下边界,从左到右)和 (G) 到 (L)(上边界,从右到左)。当然,您可以根据个人喜好调整坐标。为了填充域,我使用了pattern=north east linestikzlibrary 中的值patterns

完整代码如下:

\documentclass[tikz, border=5pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{hobby, patterns}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[axis lines=center, 
              xmin=-1, xmax=8, ymin=-1, ymax=8, 
              line width=1pt, 
              xtick={2, 6}, xticklabels={$a$, $b$}, 
              ytick={2, 6}, yticklabels={},
              xlabel={\normalsize $x$}, xlabel style={yshift=-.5*\pgfkeysvalueof{/pgfplots/major tick length},anchor=north east,inner xsep=0pt}, 
              ylabel={\normalsize $y$}, ylabel style={xshift=-.5*\pgfkeysvalueof{/pgfplots/major tick length}, anchor=north east, inner ysep=0pt}
              ]    
        
        % define the coordinates (interpolation points) for the lower boundary
        \coordinate (A) at (2,2);
        \coordinate (B) at (2.2,2.3);
        \coordinate (C) at (3,1.9);
        \coordinate (D) at (4,2.3);
        \coordinate (E) at (5,1.8);
        \coordinate (F) at (6,2);
        
        % define the coordinates (interpolation points) for the upper boundary
        \coordinate (G) at (6,6); 
        \coordinate (H) at (5,6.2);
        \coordinate (I) at (4,5.8);
        \coordinate (J) at (3,6.1);
        \coordinate (K) at (2.2,5.7);
        \coordinate (L) at (2,6);

        % draw the domain as a single closed curved that interpolates through A, B, C, D, E and F runs straight to G interpolates through H, I, J, K and L and runs again straight to A
        \draw[pattern=north east lines, pattern color=red] (A) to [curve through = {(B) (C) (D) (E)}] (F) to (G) to [curve through = {(H) (I) (J) (K)}] (L) to (A);

        % draw the dashed red lines
        \draw[red, dashed] (2,0) -- (A);
        \draw[red, dashed] (6,0) -- (F);
        
        % add the function name to the upper and lower boundary
        \node at (4,6.5) {$\beta (x)$};
        \node at (4,1.5) {$\alpha (x)$};

    \end{axis}
\end{tikzpicture}
\end{document}

结果如下:

在此处输入图片描述

相关内容