2

how do you get a box around the legends with lines instead of nodes?? Im stuck abit.

Background Info

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[upright]{fourier}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tkz-kiviat,numprint,fullpage}
\usepackage{pgfplots}
\usetikzlibrary{arrows,fit}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

 \newcommand{\LegendBox}[3][]{%
  \xdef\fitbox{}%
   \coordinate[#1] (LegendBox_anchor) at (#2) ;
    \foreach \col/\item [count=\hi from 0] in {#3} {
\draw[line width=3mm,color=\col] ([yshift=\hi*8mm]LegendBox_anchor) -- ++(.5,0) 
                                node[anchor=west][color=black] {\item}
                                ;}

   \node [draw,fit=\fitbox(LegendBox_anchor)]{};
  }

    \begin{document}
   \begin{tikzpicture}[label distance=.15cm,scale=0.75]
   \begin{scope}[rotate=30]
    \tkzKiviatDiagram[radial=3,lattice=7,gap=1,step=1,label space=2]%
    {Cover,
    Droppings,
    Other}
    \tkzKiviatLine[thick,color=red,fill=red,label=SiteA](0.78,5.59,2.02)
    \tkzKiviatLine[thick,color=blue,fill=blue](5.92,1.57,3.06)
    \tkzKiviatLine[thick,color=green,fill=green](2.9,4.6,3.6)
    \tkzKiviatGrad[suffix=\%,unity=10](0)
    \end{scope}
     \LegendBox[shift={(-3cm,-3cm)}]{current bounding box.south east}%
      {red/red decription,
       blue/blue description,
       green/green }

      \end{tikzpicture}
      \end{document}

enter image description here

1 Answer 1

2

With manual adjustments, you can from coordinate (LegendBox_anchor) draw a rectangle which includs legends

Just replace

\node [draw,fit=\fitbox(LegendBox_anchor)]{}; 

With

\draw ([shift={(-.2,-.4)}]LegendBox_anchor)rectangle([shift={(4.5,2)}]LegendBox_anchor);

In this case you do not need fit library

Code

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[upright]{fourier}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tkz-kiviat,numprint,fullpage}
\usepackage{pgfplots}
\usetikzlibrary{arrows}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

 \newcommand{\LegendBox}[3][]{%
    \coordinate[#1] (LegendBox_anchor) at (#2) ;
    \foreach \col/\item [count=\hi from 0] in {#3} {
\draw[line width=3mm,color=\col] ([yshift=\hi*8mm]LegendBox_anchor) -- ++(.5,0)
                                node[anchor=west][color=black] {\item}
                                ;}
   \draw ([shift={(-.2,-.4)}]LegendBox_anchor)rectangle([shift={(4.5,2)}]LegendBox_anchor);
  }

\begin{document}
   \begin{tikzpicture}[label distance=.15cm,scale=0.75]
   \begin{scope}[rotate=30]
   \tkzKiviatDiagram[radial=3,lattice=7,gap=1,step=1,label space=2]%
    {Cover,
    Droppings,
    Other}
   \tkzKiviatLine[thick,color=red,fill=red,label=SiteA](0.78,5.59,2.02)
   \tkzKiviatLine[thick,color=blue,fill=blue](5.92,1.57,3.06)
   \tkzKiviatLine[thick,color=green,fill=green](2.9,4.6,3.6)
   \tkzKiviatGrad[suffix=\%,unity=10](0)
   \end{scope}
   \LegendBox[shift={(-3cm,-3cm)}]{current bounding box.south east}%
      {red/red decription,
       blue/blue description,
       green/green }

   \end{tikzpicture}
   \end{document}   

Output

enter image description here

You must log in to answer this question.

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