
答案1
- 定義
domain=-5:5
require,pgfplots
下面-4
繪製複雜的函數,什麼是不可能的。如此明智的是,域下限是-4
. - 與函數 at 的切線
x=-4
是正交的,因此預設的樣本數量太小,無法跟隨函數的變化
最簡單的解決方案是
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel={$y$},
axis lines=center,
%samples=400% for more smuth curve
]
\addplot[domain=-4:5, color=red] {sqrt(x+4)-2};
\end{axis}
\end{tikzpicture}
\end{document}
這使
答案2
如果您只是意識到您正在繪製的是翻轉的拋物線,那麼您不需要任何大量的樣本。
\documentclass[margin=3pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel={$y$},
axis lines=center]
\addplot[domain=-2:1.5, color=red] ({(x+2)^2-4},{x});
\end{axis}
\end{tikzpicture}
\end{document}