我正在尝试画出这条双曲线。我试过
\documentclass[tikz,border=3mm]{standalone}
%\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{1}
\pgfmathsetmacro{\b}{1}
\draw[thick, ->] (-6,0) -- (6,0) node[right]{$x$};
\draw[thick, ->] (0,-6) -- (0,8) node[above]{$y$};
\draw (0,4) node[right]{$4$};
\draw [fill=black] (0,4) circle (1.5pt);
\draw [fill=black] (0,0) circle (1.5pt);
\draw[thick] plot[domain=-2.5:2.5] ({\a*cosh(\x)},{\b*sinh(\x)});
\draw[thick] plot[domain=-2.5:2.5] ({-\a*cosh(\x)},{\b*sinh(\x)});
\draw[thick] (0,0) circle[radius = 1];
\draw[thick] (0,4) circle[radius = 3];
\end{tikzpicture}
\end{document}
我该如何修复?
答案1
我想现在我可能理解得更清楚了。你想改变绘图范围。据我所知,目前asinh
pgf 中还没有实现,但对于中等大小的负参数,你可以近似
sinh(x) = (exp(x) - exp(-x))/2 ~ -exp(-x)/2 for x << -1
这意味着
asinh(x) ~ -2 ln(|x|)。
因此,我们可以选择域为domain=-{ln(4)}:3
,
\documentclass[tikz,border=3mm]{standalone}
%\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{1}
\pgfmathsetmacro{\b}{1}
\draw[thick, ->] (-6,0) -- (6,0) node[right]{$x$};
\draw[thick, ->] (0,-2) -- (0,8) node[above]{$y$};
\draw (0,4) node[right]{$4$};
\draw [fill=black] (0,4) circle (1.5pt);
\draw [fill=black] (0,0) circle (1.5pt);
\begin{scope}
\draw[thick] plot[domain=-{ln(4)}:3] ({\a*cosh(\x)},{\b*sinh(\x)});
\draw[thick] plot[domain=-{ln(4)}:3] ({-\a*cosh(\x)},{\b*sinh(\x)});
\end{scope}
\draw[thick] (0,0) circle[radius = 1];
\draw[thick] (0,4) circle[radius = 3];
\end{tikzpicture}
\end{document}
或者我们也可以只剪辑。
\documentclass[tikz,border=3mm]{standalone}
%\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{1}
\pgfmathsetmacro{\b}{1}
\draw[thick, ->] (-6,0) -- (6,0) node[right]{$x$};
\draw[thick, ->] (0,-2) -- (0,8) node[above]{$y$};
\draw (0,4) node[right]{$4$};
\draw [fill=black] (0,4) circle[radius=1.5pt] (0,0) circle[radius=1.5pt];
\clip (-6,-2) rectangle (6,8);
\draw[thick] plot[domain=-2.5:2.5] ({\a*cosh(\x)},{\b*sinh(\x)});
\draw[thick] plot[domain=-2.5:2.5] ({-\a*cosh(\x)},{\b*sinh(\x)});
\draw[thick] (0,0) circle[radius = 1];
\draw[thick] (0,4) circle[radius = 3];
\end{tikzpicture}
\end{document}
使用 pgfplots 这变得几乎微不足道:ymin=-2
。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{1}
\pgfmathsetmacro{\b}{1}
\begin{axis}[axis lines=middle,xtick=\empty,ytick={4},
xlabel=$x$,ylabel=$y$,axis equal image,
ymin=-2,ymax=8,
domain=-2.5:2.5]
\draw [fill=black] (0,4) circle[radius=1.5pt] (0,0) circle[radius=1.5pt];
\addplot[thick] ({\a*cosh(x)},{\b*sinh(x)});
\addplot[thick] ({-\a*cosh(\x)},{\b*sinh(\x)});
\draw[thick] (0,0) circle[radius = 1];
\draw[thick] (0,4) circle[radius = 3];
\end{axis}
\end{tikzpicture}
\end{document}