I am trying to plot a function but something is incorrectly written... Could anyone please help me?

\usepackage{amsmath, tikz}


\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}$};
  • 1
    Please upload a complete example, i.e. with class declaration and everything necessary for it to be executed "out of the box". Jan 17, 2015 at 17:10
  • 1
    You are dividing by zero at \x=0.8
    – JBantje
    Jan 17, 2015 at 17:15
  • What is problem? Please explain in some details.
    – user31034
    Jan 17, 2015 at 17:19
  • 1
    I would separate it in two graphs : one with [domain = 0.1:0.7] and the other with [domain = 0.9:10] (or something like that). Jan 17, 2015 at 17:32
  • 1
    Separating the plot into two is the only way, to get this working with the simple plot command. With 'pgfplots` however there are ways to get this done as @percusse demonstrated in his answer. If you are going to use more plots in the future, I recommend reading the manual of pgfplots, it is really powerful, but it takes some time to get used to it.
    – JBantje
    Jan 17, 2015 at 18:22

1 Answer 1


Use pgfplots

restrict y to domain=-10:10,
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}$};

enter image description here

  • thanks a lot @percusse, but why I got this message? ! Package pgfkeys Error: Choice '1.11' unknown in choice key '/pgfplots/compat/ Jan 17, 2015 at 17:58
  • @PauloSousa You need to update your package then. Current version 1.11 but probably you have an older one
    – percusse
    Jan 17, 2015 at 18:06
  • Probably, because your pgfplots is not up to date. Update it via the management tools of your TeX-Distribution.
    – JBantje
    Jan 17, 2015 at 18:10
  • @PauloSousa the example of percusse will also work if you write compat=1.10 or (probably) compat=1.9. This key ensures that graphics remain compatible even if new releases of pgfplots change something. Jan 17, 2015 at 18:46
  • compat=1.10 worked fine Jan 18, 2015 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.