填充两条以上曲线之间的区域(使用 TikZ)

填充两条以上曲线之间的区域(使用 TikZ)

这是我在这里的第一篇帖子,所以我正在学习如何使用网站的不同功能。如果有任何尴尬,请见谅...

我想填充 x 轴、曲线和双曲线之间的区域。我已经在其他帖子中找到了答案,但我还在努力寻找符合我想要的解决方案。

这是我想要填充的内容,或者只是 x 轴两侧的两个部分之一(使用 Paint 制作):

在此处输入图片描述

以下是我的序言:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[top=60pt, bottom=60pt, left=60pt, right=60pt]{geometry}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{mathrsfs}
\usepackage{fancyhdr}
\usepackage{adjustbox}
\usepackage{mathtools}
\usepackage{titlesec}
\usepackage{relsize}
\usepackage{setspace}
\usepackage{mathrsfs}
\usepackage{sectsty}
\usepackage{xcolor}
\usepackage{array}
\usepackage{comment}
\sectionfont{\centering}

\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.16}
\usetikzlibrary{patterns}

\DeclareMathOperator{\sh}{sh}
\DeclareMathOperator{\ch}{ch}
\let\th\relax
\DeclareMathOperator{\th}{th}

\definecolor{magenta}{RGB}{240, 25, 255}
\def\radius{4}
\def\zoom{1.8}
\def\point{1.3}

\centering
\onehalfspacing

这是我当前的代码:

\begin{tikzpicture}
    % Axes
    \coordinate (O) (0,0);
    \draw [->, name path=X] ({-\radius},0)--(\radius,0) coordinate (x) node[xshift=10]{$x$};
    \draw [->, name path=Y] (0,{-\radius})--(0,\radius) coordinate (y) node[yshift=10]{$y$};
    \draw (O) circle (\zoom*1); % Cercle unité
    % Hyperboles (équation)
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=right] plot ({\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=left] plot ({-\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    % Droites
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {\x});
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {-\x});
    \draw [thick, name path=A] (O)--({\zoom*cosh(\point)},{\zoom*sinh(\point)}) coordinate (M);
    \draw [thick, name path=B] (O)--({\zoom*cosh(\point)},{-\zoom*sinh(\point)}) coordinate (M');
    % ch
    \draw [line width=1, blue] (O)--({\zoom*cosh(\point)},0);
    \draw [thick, blue, densely dashed] (M)--({\zoom*cosh(\point)},0) coordinate (ch) node[yshift=-10]{$\ch{a}$};;
    \fill [blue] (ch) circle (0.055);
    % sh
    \draw [line width=1, red] (0,{\zoom/tanh(\point)})--(0,{\zoom*sinh(\point)});
    \draw [thick, red, densely dashed] (M)--(0,{\zoom*sinh(\point)}) coordinate (sh) node[xshift=-15]{$\sh{a}$};
    \fill [red] (sh) circle (0.055);
    % th
    \draw [name path=T] (\zoom,-3)--(\zoom,3);
    \draw [line width=1, magenta] (\zoom,0)--(\zoom,{\zoom*tanh(\point)}) coordinate (th) node[xshift=-15, yshift=10]{$\th{a}$};
    \fill [magenta] (th) circle (0.055);
    % coth
    \draw [domain=-2:4, variable=\x] plot (\x, {(-1/sinh(\point)*\x+\zoom/tanh(\point))});
    \draw [line width=1, orange] (O)--(0,{\zoom/tanh(\point)}) coordinate (coth) node[xshift=-20]{$\coth{a}$};
    \fill [orange] (coth) circle (0.055);
    % Aire
    \tikzfillbetween [of=A and B] {gray, opacity=.4};
\end{tikzpicture}

结果,我做到了:

在此处输入图片描述

答案1

欢迎光临!类似这样的事吗?

\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\sh}{sh}
\DeclareMathOperator{\ch}{ch}
\let\th\relax % <- bad practice
\DeclareMathOperator{\th}{th}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
    \def\radius{4} % <- bad practice to add these outside tikzpicture
    \def\zoom{1.8}
    \def\point{1.3}
    % Axes
    \coordinate (O) at (0,0);
    \draw [->, name path=X] ({-\radius},0)--(\radius,0) coordinate (x) node[xshift=10]{$x$};
    \draw [->, name path=Y] (0,{-\radius})--(0,\radius) coordinate (y) node[yshift=10]{$y$};
    \draw (O) circle (\zoom*1); % Cercle unité
    % Hyperboles (équation)
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=right] plot ({\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=left] plot ({-\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    % Droites
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {\x});
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {-\x});
    \draw [thick, name path=A] ({\zoom*cosh(\point)},{-\zoom*sinh(\point)})
        coordinate (M') --(O)--({\zoom*cosh(\point)},{\zoom*sinh(\point)}) coordinate (M);
    % ch
    \draw [line width=1, blue] (O)--({\zoom*cosh(\point)},0);
    \draw [thick, blue, densely dashed] (M)--({\zoom*cosh(\point)},0) coordinate (ch) node[yshift=-10]{$\ch{a}$};;
    \fill [blue] (ch) circle (0.055);
    % sh
    \draw [line width=1, red] (0,{\zoom/tanh(\point)})--(0,{\zoom*sinh(\point)});
    \draw [thick, red, densely dashed] (M)--(0,{\zoom*sinh(\point)}) coordinate (sh) node[xshift=-15]{$\sh{a}$};
    \fill [red] (sh) circle (0.055);
    % th
    \draw [name path=T] (\zoom,-3)--(\zoom,3);
    \draw [line width=1, magenta] (\zoom,0)--(\zoom,{\zoom*tanh(\point)}) coordinate (th) node[xshift=-15, yshift=10]{$\th{a}$};
    \fill [magenta] (th) circle (0.055);
    % coth
    \draw [domain=-2:4, variable=\x] plot (\x, {(-1/sinh(\point)*\x+\zoom/tanh(\point))});
    \draw [line width=1, orange] (O)--(0,{\zoom/tanh(\point)}) coordinate (coth) node[xshift=-20]{$\coth{a}$};
    \fill [orange] (coth) circle (0.055);
    % Aire
    \tikzfillbetween [of=A and right] {gray, opacity=.4};
\end{tikzpicture}
\end{document}

在此处输入图片描述

我只是将两行合并为一条路径。还请注意,我将你的序言精简为更简单的版本。交换代码时,重要的是避免随身携带不需要的东西。另外我认为

\let\th\relax
\DeclareMathOperator{\th}{th}

是不好的做法。您不能只给数学运算符一个不同的宏吗?

相关内容