This question led to a new package:
tkz-kiviat
Is there a way to draw Kiviat diagrams easily?
tkz-kiviat
This question led to a new package:
tkz-kiviat
Is there a way to draw Kiviat diagrams easily?
I created a package to create tkz-kiviat diagram from a file.date . I add another example in this post how-to-draw-kiviat-diagrams
The example number 5 kiviat example used an external file. My package is based on TikZ and pgfplotstable.
:
You can see that I use a lot of options ans styles from TikZ
\begin{tikzpicture}
\tkzKiviatDiagramFromFile[
scale=.5,
label distance=.5cm,
gap = 1,label space=3,
lattice = 10]{tableae.dat}
\tkzKiviatLineFromFile[thick,
color = blue,
mark = ball,
ball color = blue,
mark size = 4pt,
fill = blue!20]{tableae.dat}{2}
\tkzKiviatLineFromFile[thick,
color = red,
mark = ball,
ball color = red,
mark size = 4pt,
fill = red!20]{tableae.dat}{1}
\end{tikzpicture}
An example for my alternate approach with TikZ
nodes:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{xifthen}
\usepackage{wasysym}
\newcommand{\myshape}{circle}
\newcommand{\myfillcolor}{white}
\newcommand{\mydrawcolor}{black}
\newcommand{\myfontcolor}{black}
\newcommand{\mynodecontent}{black}
\newcommand{\multiscale}[2]{% mode, planet
\ifthenelse{\equal{#1}{passive}}{\renewcommand{\mydrawcolor}{green!70!blue}}{}
\ifthenelse{\equal{#1}{active}}{\renewcommand{\mydrawcolor}{red!80!yellow}}{}
% ---------
\ifthenelse{\equal{#2}{Mercury}}{\renewcommand{\myfillcolor}{black!75}\renewcommand{\mynodecontent}{\mercury}}{}
\ifthenelse{\equal{#2}{Venus}}{\renewcommand{\myfillcolor}{black!50}\renewcommand{\mynodecontent}{\venus}}{}
\ifthenelse{\equal{#2}{Earth}}{\renewcommand{\myfillcolor}{black!25}\renewcommand{\mynodecontent}{\earth}}{}
\node[color=-\mydrawcolor,draw=\mydrawcolor,fill=\myfillcolor,circle,ultra thick,minimum size=1cm] {\textbf{\mynodecontent}};
}
\begin{document}
\begin{tikzpicture}
\multiscale{passive}{Mercury}
\end{tikzpicture}
\begin{tikzpicture}
\multiscale{passive}{Venus}
\end{tikzpicture}
\begin{tikzpicture}
\multiscale{passive}{Earth}
\end{tikzpicture}
\begin{tikzpicture}
\multiscale{active}{Mercury}
\end{tikzpicture}
\begin{tikzpicture}
\multiscale{active}{Venus}
\end{tikzpicture}
\begin{tikzpicture}
\multiscale{active}{Earth}
\end{tikzpicture}
\end{document}
In this case, passive
is green frame, active
is red frame, and the planets become lighter gray outwards from the sun. Of course, you'd have to provide a nice key for explanation.
Edit 1: I've had a look at the documentation of tkz-kiviat
and as far as I can see it is not possible. I made a little concept how it might work, but it need horribly much manual tweaking. Also, i have no idea about text labels as pgfmath
can only extract numbers from array like structures. Probably you can also ask Altermundus, the author of tkz-kiviat
and also a user on this site.
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\newcommand{\kivaxisnumbers}{3}
\newcommand{\kivcategorycounts}{{2,3,4}}
\newcommand{\kivkumulativecategorycounts}{{0,2,5}}
\newcommand{\kivcategorynames}{{1,2,10,20,30,100,200,300,400}}
\newcommand{\kivlcmcatcount}{12}
\newcommand{\kivlattice}{%
\pgfmathsetmacro{\kivaxisangle}{360/\kivaxisnumbers}
\foreach \x in {1,...,\kivaxisnumbers}
{ \foreach \y in {1,...,\kivlcmcatcount}
{ \pgfmathsetmacro{\kivaxisstep}{6/\kivlcmcatcount}
\draw[help lines] (\kivaxisangle*\x:\y*\kivaxisstep) -- (\kivaxisangle*\x+\kivaxisangle:\y*\kivaxisstep);
}
}
\foreach \x in {1,...,\kivaxisnumbers}
{ \draw[->] (0,0) -- (\kivaxisangle*\x:6cm);
\pgfmathsetmacro{\kivaxissteps}{\kivcategorycounts[\x-1]}
\pgfmathsetmacro{\kivaxisstep}{6/\kivcategorycounts[\x-1]}
\foreach \y in {1,...,\kivaxissteps}
{ \pgfmathsetmacro{\kivhelper}{\kivkumulativecategorycounts[\x-1]}
\pgfmathtruncatemacro{\kivlabelname}{\kivcategorynames[\kivhelper+\y-1]}
\node[circle,fill=black,label=\x*\kivaxisangle+90:\kivlabelname,inner sep=1pt] at (\kivaxisangle*\x:\kivaxisstep*\y) {};
}
}
}
\begin{document}
\begin{tikzpicture}
\kivlattice
\end{tikzpicture}
\end{document}
Edit 2: For adding some data (in percentages of the axes):
\newcommand{\kivdatapoints}{}
\newcommand{\kivdata}[2]{% values in percentages of max, color
\renewcommand{\kivdatapoints}{{#1}}
\pgfmathsetmacro{\kivaxisangle}{360/\kivaxisnumbers}
\pgfmathsetmacro{\kivcoordinate}{\kivdatapoints[0]*6}
\fill[opacity=0.2,#2] (\kivaxisangle:\kivcoordinate)
\foreach \x in {1,...,\kivaxisnumbers}
{ %\pgfmathsetmacro{\kivcoordinate}{\kivdatapoints[\x-1]*6}
-- (\kivaxisangle*\x:\kivdatapoints[\x-1]*6)
}
-- cycle;
}
\begin{document}
\begin{tikzpicture}
\kivlattice
\kivdata{0.2,0.9,0.6}{red}
\kivdata{0.7,0.1,0.8}{green}
\kivdata{0.4,0.35,0.3}{blue}
\end{tikzpicture}
Edit 3: Thanks to Brandon Kuczenski's answer in this question, I was able to add text labels to the axes:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{arrayjobx}
\makeatletter
\usepackage{trimspaces}
\def\trimspace#1{\trim@spaces@in{#1}}
\makeatother
\newarray\kivaxisitemlabels
\readarray{kivaxisitemlabels}{%
Decision & Yes & No & & &
Color & Red & Blue & Yellow & &
Direction & North & East & South & West &
Taste & Sour & Salty & Bitter & Sweet &
World & Normal & Nether & End & }
\dataheight=5
\newcommand{\kivcurrentlabel}[2]{\checkkivaxisitemlabels(#1,#2)\trimspace\cachedata \cachedata}
\newcommand{\kivaxisnumbers}{5}
\newcommand{\kivcategorycounts}{{2,3,4,4,3}}
\newcommand{\kivkumulativecategorycounts}{{0,2,5,9,13}}
%\newcommand{\kivcategorynames}{{1,2,10,20,30,100,200,300,400}}
\newcommand{\kivlcmcatcount}{12}
\newcommand{\kivlattice}{%
\pgfmathsetmacro{\kivaxisangle}{360/\kivaxisnumbers}
\foreach \x in {1,...,\kivaxisnumbers}
{ \foreach \y in {1,...,\kivlcmcatcount}
{ \pgfmathsetmacro{\kivaxisstep}{6/\kivlcmcatcount}
\draw[help lines] (\kivaxisangle*\x:\y*\kivaxisstep) -- (\kivaxisangle*\x+\kivaxisangle:\y*\kivaxisstep);
}
}
\foreach \x in {1,...,\kivaxisnumbers}
{ \draw[->] (0,0) -- (\kivaxisangle*\x:6cm);
\pgfmathsetmacro{\kivaxissteps}{\kivcategorycounts[\x-1]}
\pgfmathsetmacro{\kivaxisstep}{6/\kivcategorycounts[\x-1]}
\foreach \y in {1,...,\kivaxissteps}
{ %\pgfmathsetmacro{\kivhelper}{\kivkumulativecategorycounts[\x-1]}
%\pgfmathtruncatemacro{\kivlabelname}{\kivcategorynames[\kivhelper+\y-1]}
%\node[circle,fill=black,label=\x*\kivaxisangle+90:\kivlabelname,inner sep=1pt] at (\kivaxisangle*\x:\kivaxisstep*\y) {};
\pgfmathtruncatemacro{\kivlabelnumber}{\y+1}
\node[circle,fill=black,label=\x*\kivaxisangle+90:\kivcurrentlabel{\x}{\kivlabelnumber},inner sep=1pt] at (\kivaxisangle*\x:\kivaxisstep*\y) {};
}
}
}
\newcommand{\kivdatapoints}{}
\newcommand{\kivdata}[2]{% values in percentages of max, color
\renewcommand{\kivdatapoints}{{#1}}
\pgfmathsetmacro{\kivaxisangle}{360/\kivaxisnumbers}
\pgfmathsetmacro{\kivcoordinate}{\kivdatapoints[0]*6}
\fill[opacity=0.2,#2] (\kivaxisangle:\kivcoordinate)
\foreach \x in {1,...,\kivaxisnumbers}
{ %\pgfmathsetmacro{\kivcoordinate}{\kivdatapoints[\x-1]*6}
-- (\kivaxisangle*\x:\kivdatapoints[\x-1]*6)
}
-- cycle;
}
\begin{document}
\begin{tikzpicture}
\kivlattice
\kivdata{0.2,0.9,0.6,0.5,0.5}{red}
\kivdata{0.7,0.1,0.8,0.6,.2}{green}
\kivdata{0.4,0.35,0.3,0.25,0.2}{blue}
\end{tikzpicture}
\end{document}
Best Answer
It was interesting to make a package to use TikZ to build Kiviat Diagram. This package is now on CTAN:
tkz-kiviat
. You can find some examples on my homepage: kiviat examples.The first example uses three macros with arguments. First, you create a spider, then you can create a kiviat polygon and you can create graduations
Another solution is to use an external file with data
The tableae.dat file is used with the package pgfplotstable.sty