3

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

Count Zero
  • 17,424

0 Answers0