我正在尝试绘制一个函数,但是有些东西写错了...有人可以帮帮我吗?
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath, tikz}
\usepackage[margin=3cm]{geometry}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[scale=0.45]
\draw[->] (-1,0) -- (10,0) node[below] {$x$};
\draw[->] (0,-1) -- (0,10) node[above] {$y$};
\draw[dotted] (1.4,3.33) -- (1.4,0);
\draw[dotted] (0,3.33) -- (1.4,3.33) node[left = 0.65cm] {$\frac{10}{3}$};
\draw [domain=0.1:10] plot (\x,{2/(\x-0.8)}) node[right] {$f(x)=\frac{10}{5x-4}$};
\end{tikzpicture}
\end{document}
答案1
使用pgfplots
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:5,samples=150,
restrict y to domain=-10:10,
xtick=\empty,ytick=\empty,
extra x ticks={0.8,1.4},
extra y ticks=3.333333,extra y tick labels={$\frac{10}{3}$},
grid=both,axis lines=middle
]
\addplot+[no marks] {2/(x-0.8)} node[above left] {$f(x)=\frac{10}{5x-4}$};
\end{axis}
\end{tikzpicture}
\end{document}