如何在 tikz 中绘制 af(x)=1/x 图?
任何帮助都将非常感谢,谢谢!
答案1
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-5,-4,...,5},
xmin=-5,
xmax=5,
xlabel={\tiny $x$},
axis x line=middle,
ytick={-5,-4,...,5},
tick label style={font=\tiny},
ymin=-5,
ymax=5,
ylabel={\scriptsize $f(x)=1/x$},
axis y line=middle,
no markers,
samples=100,
domain=-5:5,
restrict y to domain=-5:5
]
\addplot[thick,samples=400] (x,{1/x});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}