尝试在 [-1,1] 上绘制曲线 $x=t, y=\sqrt(1-t^2)$,
\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}
[xlabel=$x$,ylabel=$y$,axis lines=middle,xtick={2},ytick={2},
no marks,axis equal,xmin=-1.4,xmax=1.2,ymax=1.2,ymin=-0.2,enlargelimits={upper=0.1}]
\addplot[no markers,samples=100, domain=-1:1,variable=t]({t},{sqrt(1-(t)^2)});
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
我收到 PGF 数学错误:抱歉,浮点内部例程...
我哪里错了?
后来的编辑:根据@Cragfelt 的评论,我编写了完整的代码。
答案1
\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[xlabel=$x$,ylabel=$y$,axis lines=middle,xtick={2},ytick={2},
no marks,axis equal,xmin=-1.4,xmax=1.2,ymax=1.2,ymin=-0.2,enlargelimits={upper=0.1}]
\addplot[no markers,samples=100,
domain=-1:1,variable=t]({t},{pow(1-t^2,1/2)});
\end{axis}
\end{tikzpicture}
\end{document}