答案1
你可以这样pgfplots
做掠夺建议或使用tikz
(还有更多选项),如我的示例所示。
我使用\foreach
命令是因为要绘制的区域和曲线都是对称的,所以我避免重复的代码。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\xmax{4};
% grid
\draw[help lines] (-\xmax,-\xmax) grid (\xmax,\xmax);
% axes
\draw[-latex] (-\xmax,0) -- (\xmax,0) node [right] {$x$};
\draw[-latex] (0,-\xmax) -- (0,\xmax) node [above] {$y$};
% a little bit of the hyperbola goes out of the grid so I'm clipping it
\clip (-\xmax,-\xmax) rectangle (\xmax,\xmax);
\foreach\i in {-1,1} % to draw the following twice
{%
\draw[thick,blue,fill=yellow,fill opacity=0.4] (0,0) -- (\i*\xmax,-\xmax)
-- plot[smooth,domain=-\xmax:\xmax] ({\i*sqrt(1+\x*\x)},\x)
-- (\i*\xmax,\xmax) -- cycle; % curve(s) and yellow regoin(s)
\draw[thick,red] (\i*\xmax,-\xmax) -- (0,0) -- (\i*\xmax,\xmax); % asymptote(s)
}
\end{tikzpicture}
\end{document}
答案2
如果你编译这个:
\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=4]
\filldraw[fill=cyan,draw=black,domain={-sqrt(3)}:{sqrt(3)},variable=\y,samples=100]
(2,-{sqrt(3)})--(2,-2)--plot({sqrt(\y*\y+1)},\y)--(2,2)--(0,0)--(2,-2)--cycle;
\filldraw[fill=cyan,draw=black,domain={-sqrt(3)}:{sqrt(3)},variable=\y,samples=100]
(-2,-{sqrt(3)})--(-2,-2)--plot({-sqrt(\y*\y+1)},\y)--(-2,2)--(0,0)--(-2,-2)--cycle;
\end{tikzpicture}
\end{document}
你会得到这个: