人工边界条件

人工边界条件

这是一个目标数字。 在此处输入图片描述

我的代码的输出是在此处输入图片描述 不幸的是,我无法填写右侧。请​​帮助我。

\documentclass{article}‎
‎\usepackage{tikz}‎‎
‎\begin{document}‎
‎\begin{tikzpicture}[scale=1.5]‎‎
‎\fill[blue!‎1‎5‎!white] (‎-5‎,‎4‎) rectangle (‎-1.5‎,‎0‎)‎;‎‎
‎\draw ‎[‎thick, ‎gray,‎‎‎‎‎->] (-5,0)--(‎4‎,0) node[right‎, ‎below] {$x$};‎
‎\draw ‎[‎thick,‎‎gray,‎->] (0,0)--(0,4) node[above‎, ‎left] {$y$};‎‎
‎\draw ‎[‎very ‎‎thick,‎red‎‎] (‎-‎1.5‎‎,0)--(‎-1‎.5‎‎,4)‎‎ node[above‎, ‎above‎] {$‎TBC‎$};‎‎
‎‎‎‎\draw[color=‎p‎urple‎!‎6‎‎‎0‎‎,‎smooth‎,‎very ‎thick‎, domain=‎0‎‎‎‎‎:‎1.9‎8‎‎‎‎‎‎‎‎‎‎‎‎‎‎] plot (\x, ‎{‎‎\x*\x‎‎‎})‎;‎‎
‎\node[] at (‎-1.5‎,-0.15) {$‎a‎$};‎‎
‎\node[] at (‎-‎5‎‎,-0.15) {$‎-‎\infty‎‎‎$};‎‎
‎\node[] at (‎-‎5‎.2‎‎‎,‎4‎) {$‎\tau$‎};‎‎‎‎
‎\node[] at (‎-1.‎2‎‎,‎2‎.1‎‎) {$‎\Gamma_a‎‎$};‎‎
‎\node[] at (‎1.‎1‎‎‎,‎2‎.1‎‎) {$‎x_f(\tau)‎‎‎$};‎‎
‎\node[] at (‎0.‎2‎‎‎‎‎,‎-0.15‎‎‎) {$‎x_f(‎0‎)‎=0‎$};‎‎
‎\node[] at (‎-‎3‎‎‎,‎2‎) {$‎\Omega‎_‎e‎‎‎‎$};‎‎
‎\end{tikzpicture}‎

‎ \{文档}

答案1

我认为您不想使用 pgfplots 及其fillbetween库。您的问题很简单,因此无需使用这些即可解决。如果您有更复杂的图,我建议使用这些(或至少)fillbetween

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\fill[blue!15!white] (-5,4) rectangle (-1.5,0);
\draw [thick, gray,->] (-5,0)--(4,0) node[right, below] {$x$};
\draw [thick,gray,->] (0,0)--(0,4) node[above, left] {$y$};
\draw [very thick,red] (-1.5,0)--(-1.5,4) node[above, above] {$TBC$};
\draw[color=purple!60,smooth,very thick, domain=0:1.98] plot (\x, {\x*\x});
\begin{scope}[on background layer]
\path[fill=purple!30] plot[smooth,domain=0:1.98] (\x, {\x*\x}) coordinate (aux)
-- (4,0 |-aux)|- (0,0);
\end{scope}
\node[] at (-1.5,-0.15) {$a$};
\node[] at (-5,-0.15) {$-\infty$};
\node[] at (-5.2,4) {$\tau$};
\node[] at (-1.2,2.1) {$\Gamma_a$};
\node[] at (1.1,2.1) {$x_f(\tau)$};
\node[] at (0.2,-0.15) {$x_f(0)=0$};
\node[] at (-3,2) {$\Omega_e$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我个人认为这种图表更容易理解元帖子您可以将路径作为变量处理,并创建想要填充的形状而无需剪切或范围等,但这可能只是因为我不太了解 TikZ!

这是我的努力,希望它有价值。

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    numeric u;
    u = 2cm;

    path xx, yy, ff;

    xx = (5 left -- 4 right) scaled u;
    yy = (origin -- 4 up) scaled u;

    numeric s; s = 1/4;
    ff = (origin for x=s step s until 2: .. (x, x*x) endfor) scaled u;

    numeric a;
    a = -1;

    path exterior, interior, external;

    exterior = point 0 of xx -- (a*u,0) -- (a*u, ypart point infinity of yy) -- (xpart point 0 of xx, ypart point infinity of yy) -- cycle;
    interior = (a*u,0) -- ff -- (a*u, ypart point infinity of yy) -- cycle;
    external = origin -- point infinity of xx -- (xpart point infinity of xx, ypart point infinity of yy) -- reverse ff -- cycle;

    fill exterior withcolor 7/8[blue, white];
    fill interior withcolor 15/16 white;
    fill external withcolor 7/8[red + 1/2 green, white];

    draw ff withcolor 1/3 [red, blue];
    draw subpath (1, 2) of exterior withcolor 2/3 red;

    drawarrow xx;
    drawarrow yy;

    label.bot("$x$", point infinity of xx);
    label.bot("$-\infty$", point 0 of xx);
    label.top("$\tau$", point infinity of yy);

    label.rt("$\Gamma_a$", point 3/2 of exterior);
    label.ulft("$x_f(\tau)$", point 6 of ff);

    label("$\Omega_e = \hbox{Exterior Domain}$", center exterior);

endfig;
\end{mplibcode}
\end{document}

相关内容