I want to draw a spider/kiviat diagram. I am using the tkz-kiviat
library but I have some problems. Here is my MWE
\documentclass[xcolor={dvipsnames}]{beamer}
\usetheme{Warsaw}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{eurosym}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepackage[upright]{fourier}
\usepackage{tkz-kiviat,numprint}
\usetikzlibrary{decorations.pathreplacing, arrows, fit}
\usepackage{graphicx}
\usepackage{url}
\usepackage{booktabs}
\usepackage{textcomp}
\usepackage{epstopdf}
\usepackage{hhline}
\usepackage{xmpmulti}
\usepackage{siunitx}
\usepackage{adjustbox}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
%\setbeamercolor{title}{fg=red!80!black}
%\setbeamertemplate{items}[circle]
\newcommand{\LegendBox}[3][]{%
\xdef\fitbox{}%
\coordinate[#1] (LegendBox_anchor) at (#2) ;
\foreach \col/\item [count=\hi from 0] in {#3} {
\node[color = \col,draw,
fill = \col!50,
minimum width = 4 ex,
minimum height = 2 ex,
label={[anchor = left,name=b\hi]right :\item}] at ([yshift=\hi*4 ex]LegendBox_anchor) {};
\xdef\fitbox{\fitbox(b\hi)}
}%
\node [draw,fit=\fitbox(LegendBox_anchor)] {};
}
\title{MWE}
\date{\today}
\usepackage[T1]{fontenc}
\begin{document}
\begin{frame}
\begin{adjustbox}{max totalsize={.9\textwidth}{.8\textheight},center}
\begin{tikzpicture}[label distance=.15cm]
\begin{scope}
\tkzKiviatDiagram[
radial=5,
radial style/.style ={-},
lattice style/.style ={blue!30}]
{\LARGE Exhaustivité, \LARGE Descripteurs sociologiques, \LARGE Données conditions de vie, \LARGE Richesse des informations sur le revenu, \LARGE Coût}
\tkzKiviatLine[thick,color=red,mark=ball,
ball color=red,mark size=4pt,fill=red!20](5,9,6,8,4)
\tkzKiviatLine[thick,color=blue,mark=ball,
mark size=4pt,fill=blue!20,opacity=.5](9,6,8,4,5)
\tkzKiviatLine[thick,color=green,mark=ball, ball color=green,
mark size=4pt,fill=green!20,opacity=.5](3,8,8,6,8)
\end{scope}
\LegendBox[shift={(3cm,3.5cm)}]{current bounding box.south east}%
{red/ ERFS,
blue/ FiLoSoFi,
green/ SRCV }
\end{tikzpicture}
\end{adjustbox}
\end{frame}
\end{document}
I have several things I would like to change :
- My legend is obviously wrong, I think it is something in the label of the
\LegendBox
new command, but I have not found what.
I took the code from an answer to Spider Graph Legend and Caption. - I would like the labels of my axes to be larger, that is to have my text less cut
- Last, I would like to have less lines on my diagram (each of the ten units is drawn, I would like only the even ones)
Thanks
Best Answer
Here are some modifications.
I redefined the
\LegendBox
command to produce a proper result.You can use the style
label style
to specify a biggertext width
for the labels.This requires a redefinition of
\tkz@KiviatDiagram
so the loop drawing the lines has two as step instead of one. (You should consider asking the package creatot to add an option allowing to control the stepping for the lattice). I also did some other adjustments so the anchor for the nodes containing the labels can be changed.The code:
The result:
Remarks
Since you are loading
babel
withfrenchb
option it's a good idea to load thebabel
library:There's no need to load
amsmath
norgraphicx
withbeamer
since the class internally loads them.