1

I am trying to plot a histogram by below lines

\documentclass[tikz]{standalone}
 \begin{document}
\begin{tikzpicture}[>=stealth]
 \draw[<-] (7,0) node[below] {$x$} -- (-.5,0);
 \draw[->] (0,-.5) -- (0,7) node[left] {$y$};
 \draw (0,0) grid (6,1)  (1,1) grid (2,6)  (3,1) grid (4,5) (4,1) 
  rectangle (5,2);

 \end{tikzpicture}
 \end{document}

whose extracted output is as Fig.1 (of course without the red numbers below x axis).

Fig.1

How do I insert red numbers by latex (not paint) exactly below each column, however they are not starting with 1. Instead, they begin for example from 11 here.

1
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth]
 \draw[<-] (7,0) node[below] {$x$} -- (-.5,0);
 \draw[->] (0,-.5) -- (0,7) node[left] {$y$};
 \draw (0,0) grid (6,1)  (1,1) grid (2,6)  (3,1) grid (4,5) (4,1) 
  rectangle (5,2);
 \foreach \i in {10,...,15}
    \path[red] (\i-9.5,0) node[below] {$\i$};
\end{tikzpicture}
\end{document}

enter image description here

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.