TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to make a picture that should look like


I saw a similar question here but the red function line appears neither when I use --shell-escape nor when I use --enable-write18. I use TeXstudio, by the way. TikZ and pgf packages are installed.

UPD: Code which I used


\tkzFct[color = red, domain =0.125:8]{4./x}
                     line width=1pt,
 \foreach \x/\t in {1.5/$a_1$,2.5/$a_2$,3.5/$a_3$,7.5/$a_7$}
 \node[green!50!black] at (\x,{4/(\x+1)-0.25}){\t};  

And maybe there are some good graphic editors to draw such things by hand?

share|improve this question
Can you post your code too? Which answer are you using? – percusse Apr 24 '13 at 12:30
FYI, you don't need --shell-escape to use tikz & friends. – Jubobs Apr 24 '13 at 12:31
@Jubobs: I think Danil is using the tkz solution that uses gnuplot, and therefore needs shell-escape – Jake Apr 24 '13 at 12:33
@percusse oh i used marked answer by Alain Matthes – Danil Gholtsman Apr 24 '13 at 12:37
@Jubobs yes, Jake is right. – Danil Gholtsman Apr 24 '13 at 12:38
up vote 3 down vote accepted

You could use the pgfplots answer, which does not rely on external programs to calculate the function:



% right hand sums
    right segments/.code={\pgfmathsetmacro\rightsegments{#1}},
    right segments=3,
    right/.style args={#1:#2}{
        ybar interval,
        x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\rightsegments)}

\begin{tikzpicture}[/pgf/declare function={f=4/x;}]
    axis lines=left,
    restrict y to domain=0:4
\addplot [thick, red] {f};
\addplot [
    right segments=7,
] {f};

\draw [ultra thick, black!60, -latex] (axis cs:1.5,0) -- ++(0,-5ex) node [anchor=north, black] {thread 1};
\draw [ultra thick, black!60, -latex] (axis cs:2.5,0) -- ++(0,-8ex) node [anchor=north, black] {thread 2};
\draw [ultra thick, black!60, -latex] (axis cs:7.5,0) -- ++(0,-5ex) node [anchor=north, black] {thread n};

share|improve this answer
oh, thanks it helped! – Danil Gholtsman Apr 24 '13 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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