Take the 2-minute tour ×
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.

I am trying to produce an area legend like the following picture.

enter image description here

For some reasons, the output of the following code does not produce a single box for each dataset in the legend.

\begin{tikzpicture}
\begin{axis}[
    width=\figurewidth,
    height=\figureheight,
    scale only axis,
    xmode=log,
    ymode=log,
    xlabel = {$|\mathrm{Velocity\ Divergency}|$},
    x tick label as interval=false,
    xtick={},
    xtickten={-18,-16,...,4},
    yticklabels={$0.0001\%$, $0.001\%$, $0.01\%$, $0.1\%$, $1\%$, $10\%$, $100\%$},
    xmin=1e-18, xmax=1e+4,
    ymin=1e-5,ymax=1,
    grid=none,
    ymajorgrids,    
    bar shift=0pt,
    area legend, 
    % align right:
    legend style={
                  cells={anchor=west},
                  legend pos=outer north east,
    }
]
\addplot [fill=blue!100,
    ybar interval] table [x=Lower, y=Count] {
Lower Upper Count
9.9e-15 1e-14      0.1231
1e-14   1e-13      1e-15
1e-13   1e-12      0.0000
1e-12   1e-11      0.0000
1e-11   1e-10      0.0000
1e-10   1e-9       0.0000
1e-9    1e-8       0.0000
1e-8    1e-7       0.0001
1e-7    1e-6       0.0001
1e-6    1e-5       0.0004
1e-5    1e-4       0.0010
1e-4    1e-3       0.0048
1e-3    1e-2       0.0313
1e-2    1e-1       0.1562
1e-1    1e+0       0.3464
1e+0    1e+1       0.2684
1e+1    1e+2       0.0645
1e+2    1e+3       0.0036
1e+3    1e+4       1e-15
};
\addlegendentry{Interp}
\addplot [fill=red!100, ybar interval] table [x=Lower, y=Count] {
Lower Count
1e-17 1
1e-16 1
};
\addlegendentry{Div-free}
\end{axis}
\end{tikzpicture}

It produces small bar plots beside the legend names as can be seen in the picture below. enter image description here

share|improve this question

closed as too localized by Jake, Claudio Fiandrino, Stefan Kottwitz Jan 30 '13 at 18:45

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Please create a complete minimal example document, starting from \documentclass (you should always do that), and state the version of PGFPlots you're using. I cannot reproduce this behaviour using PGFPlots v. 1.7. –  Jake Jan 30 '13 at 9:44
1  
Sorry, but what's the problem with the example I provided you in Pgfplots: Problem in adding shape to legend? –  Claudio Fiandrino Jan 30 '13 at 10:19
    
@Claudio the question in that post was asked by me. However, I was surprised when I compiled the code and saw different result. –  A2009 Jan 30 '13 at 18:05
    
@Jake, you mentioned a very good point. I checked the version and for some reasons, the version was returned to 1.4. I removed the tds file and added it again and now everything works fine. I am using version 1.7. Thanks everybody. –  A2009 Jan 30 '13 at 18:05
    
CONCLUSION: The solution was using the latest version of pfgplots. –  A2009 Jan 30 '13 at 18:09

Browse other questions tagged or ask your own question.