I try to draw a histogram with boxes. Drawing histograms with pgfplots seems extremely simple, and I'm sure what I want to to isn't any more difficult, but I couldn't find a good example. Hence the question: How do I make a graphic like the one drawn here by hand?

enter image description here

1 Answer 1


You can draw it directly in tikz without pgfplot

    \draw[fill=#6] (#1cm+\rectsep,#2cm+\rectsep) rectangle node{#5} +(#3cm-2*\rectsep,#4cm-2*\rectsep);}
  \draw[->](0,0)--(4,0)node[anchor=north west]{$V_1$};
  \draw[->](0,0)--(0,4)node[anchor=south east]{$V_2$};
  \foreach \Tick in {1,2,3}{
    \draw (\Tick,0)-- +(0,-0.2) node[below]{$\Tick00$};
    \draw[thin,gray] (\Tick,0)-- +(0,4);
    \draw (0,\Tick)-- +(-0.2,0) node[left]{$\Tick00$};
    \draw[thin,gray] (0,\Tick)-- +(4,0);
    \clip (0,0) rectangle (4.7,4.7);

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .