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.

This question led to a new package:
tkz-kiviat

Is there a way to draw Kiviat diagrams easily?

Sample Kiviat diagram

share|improve this question
    
these are both rich answers! thank you very much for your help –  adnc Feb 2 '11 at 14:50
1  
Welcome to {TeX}. I've converted your 'answer' to a comment. Usually, simple 'thanks' comments are not really encouraged, as we have a voting model for good-quality answers. You can upvote good answers, and as this is your question can also accept the 'best' one (use the tick by the answers to do this). –  Joseph Wright Feb 2 '11 at 14:52
    
I've edited the question to add one of the pictures you linked to. Once you get enough reputation you'll be able to do this yourself: for the moment, you can add a comment to your questions asking someone to do this for you, where necessary. –  Joseph Wright Feb 2 '11 at 14:55
    
Related Question: Problem drawing Kiviat diagram. –  Peter Grill Nov 6 '12 at 9:36

3 Answers 3

up vote 14 down vote accepted

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

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

\begin{document} 
\begin{tikzpicture}
\tkzKiviatDiagram[scale=1.25,label distance=.5cm,
        radial  = 5,
        gap     = 1,  
        lattice = 5]{McCabe,LOC,Live Variables,Halstead N,Variablenspanne}
\tkzKiviatLine[thick,color=blue,mark=none,
               fill=blue!20,opacity=.5](3,3.5,3,3.5,3)
\tkzKiviatLine[thick,color=darkgray,
               fill=green!20,opacity=.5](0.5,1,0.5,0.75,1) 
\tkzKiviatLine[ultra thick,mark=ball,
                 mark size=4pt,color =Maroon](2,3.75,1,1.5,2)    
\tkzKiviatGrad[prefix=,unity=100,suffix=\ \texteuro](1)  
\end{tikzpicture}

\end{document}

kiviat example

Another solution is to use an external file with data

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

\begin{document}

\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}

\end{document}

The tableae.dat file is used with the package pgfplotstable.sty

%tableae.dat
column1                    column2   column3 
Reliability                6           6.5
Usability                  4           9
{Application Architecture} 7           8
{Version Control}          6.5         7
Timeliness                 2           8
Efficiency                 3           4
Effectiveness              5           6.5
Interoperability           1.5         7 

kiviat diagram with an external file

share|improve this answer
    
unfortunately I do get an ! Undefined control sequence. <argument> 360/\tkz@kiv@radial *\rang :\tkz@kiv@lattice *\tkz@kiv@gap +\tkz@... l.15 ...Live Variables,Halstead N,Variablenspanne} What am I missing here? Does it require cvs version of tikz? I'm going with Ubuntus packed version of pgf/tikz 2.0 –  adnc Feb 7 '11 at 19:49
    
@adnc I made it with pgf 2.1 This is the new version of pgf –  Alain Matthes Feb 7 '11 at 20:25
    
@adnc you can get pgf 2.1 here sourceforge.net/projects/pgf and you can install it in your texmf. –  Alain Matthes Feb 7 '11 at 20:34
    
I again need to say that this solution is great! –  adnc Jun 28 '11 at 9:25
    
@doncherry Yes I created this package for this question –  Alain Matthes Apr 4 '13 at 19:43

I'd go fot the tikz package.

Have a look at this example.


I've written a crude set of macro's that might help you on your way when making your own (adjust these and you should be fine).

I'm not that great a programmer myself so perhaps someone else will come up with something much more refined but this will do for now. The upside to my little programming skills is that the code is easy, so you'll probably be able to grasp it quickly and adjust it to your needs.

There are 4 macro's. The main macro is \spider, it takes as much parameters as there are axes (I've written the code for 8 axes, adjust it if you need more or less using the \n command and some tweaking in the code). Each paramter of \spider stands for a value on the the corresponding axis.

\outertolerance works the same way as spider and sets the outer tolerance band for the next \spiderto take into account. The same way \innertolerance sets the values for the inner tolerance band.

Everytime a \spideris used the \outertoleranceand \innertolerance values are reset to nothing (draw no tolerance bands). You can also reset them youerself this by hand using \resettolerance

Add this to preamble:

\usepackage{tikz}

\def\n{8}   %define how much axes you want
\def\N{5}   %define the number of node on each axis

\newcommand{\spider}[\n]{
    \begin{tikzpicture}[scale=0.5]

        \thebigtolerance

        \foreach \x in{0,1,...,\n}{%
            \draw[->] (0,0)--(360/\n*\x:\N+0.5);
            \foreach \y in{0,1,...,\N}{
                \draw[thin,lightgray](360/\n*\x:\y)--(360/\n*\x+360/\n:\y);
                \draw[fill] (360/\n*\x:\y) circle(0.75pt);
                }

        }

        \draw(360/\n:\N+0.5)node[right]{axis1};     %adjust the labels (also add or delete exces axes)
        \draw(2*360/\n:\N+0.5)node[above]{axis2};   %eg. if you have 6 axes, delete the last 2
        \draw(3*360/\n:\N+0.5)node[left]{axis3};        %or if you have 9 axes add one
        \draw(4*360/\n:\N+0.5)node[left]{axis4};
        \draw(5*360/\n:\N+0.5)node[left]{axis5};
        \draw(6*360/\n:\N+0.5)node[below]{axis6};
        \draw(7*360/\n:\N+0.5)node[right]{axis7};
        \draw(8*360/\n:\N+0.5)node[right]{axis8};

        \thesmalltolerance

        \draw[thick,draw=red](360/\n:#1)--(360/\n*2:#2)--(360/\n*3:#3)--(360/\n*4:#4)--(360/\n*5:#5)--(360/\n*6:#6)--(360/\n*7:#7)--(360/\n*8:#8)--cycle;
        %add or remove coordinates if you have more or less than 8 axes


    \end{tikzpicture}
    \resettolerance 
}


\newcommand{\thesmalltolerance}[0]{}
\newcommand{\innertolerance}[\n]{
    \renewcommand{\thesmalltolerance}{\draw[fill=gray,thick,opacity=0.3](360/\n:#1)--(360/\n*2:#2)--(360/\n*3:#3)--(360/\n*4:#4)--(360/\n*5:#5)--(360/\n*6:#6)--(360/\n*7:#7)--(360/\n*8:#8)--cycle;}
    %add or remove coordinates if you have more or less than 8 axes
}

\newcommand{\thebigtolerance}[0]{}
\newcommand{\outertolerance}[\n]{
    \renewcommand{\thebigtolerance}{
        \foreach \x in{1,2,...,\n}{
            \draw[draw=none,fill=gray,opacity=0.3](0,0)--(360/\n*\x:\N)--(360/\n*\x+360/\n:\N);}

        \draw[fill=white,thick,draw=gray](360/\n:#1)--(360/\n*2:#2)--(360/\n*3:#3)--(360/\n*4:#4)--(360/\n*5:#5)--(360/\n*6:#6)--(360/\n*7:#7)--(360/\n*8:#8)--cycle;
        %add or remove coordinates if you have more or less than 8 axes
    }
}

\newcommand{\resettolerance}[0]{%resets the tolerance band to none
    \renewcommand{\thebigtolerance}{}
    \renewcommand{\thesmalltolerance}{}
}

As said above, you will need to adjust the drawing commands to fit the number of axis. This means adding (360/\n*9:#9)-- if you want nine axes. Or removing (360/\n*8:#8)-- if you want 7 axes. You should do this in 3 places (in the \spidercommand, and in \outertolerance and \innertolerance. The adjustment should be the same for every command.

You can also adjust the number of nodes on each axis by adjusting the \N number. You might have to also adjust the scaling=0.5 because more nodes means a bigger chart.

I've also made an example of how to actually draw the spider chart:

\outertolerance{4}{4}{4}{3}{4}{4}{4.5}{4}%defines the outer toleranceband for next spider
\innertolerance{1}{1}{1}{1}{1}{2}{2}{1}%defines the inner toleranceband for next spider
\spider{2}{2}{2}{2}{3}{4}{4}{3}%draws the spider diagram with coordinates

Hope this helps!

example

share|improve this answer
    
this is really good, except i would need to plot one dataset and also a toleranceband –  adnc Feb 1 '11 at 22:49
    
is this a one time deal or do you need a macro that will be used several times? –  romeovs Feb 1 '11 at 22:53
    
I'll need to produce these diagrams several times. –  adnc Feb 1 '11 at 22:55
1  
Play around with the tikz package. It provides great possibilities for drawing any diagrams. analyse the example I gave you and you'll come up with something. –  romeovs Feb 1 '11 at 23:03
    
I don't have enough time tonight but tomorrow, I can make a macro to draw these diagrams. Ineed only to know what to you want like options, variables. What is constant and i make this for you ! –  Alain Matthes Feb 1 '11 at 23:20

With the current pstricks-add.tex you can simplify it:

\documentclass{article}
\usepackage{pstricks-add}
\def\Tab#1{\tabular{@{}l@{}}#1\endtabular}
\begin{document}

\psframebox*[fillcolor=yellow!15]{%
\begin{pspicture}(-6,-5)(5,5)
\psset{unit=1.2}
\psKiviat[rotate=0.5,
          yLabels={Marketing,Sales,Administration,\Tab{Information\\Technology},%
           \Tab{Customer\\Support},Developer},
  labelsep=10pt]{6}{3}
\psKiviatTicklines[Dx=0.5,linecolor=black!30]{6}{3}
\psKiviatAxes[linecolor=black!30]{7}{3}
\psKiviatLine[linewidth=2pt,linecolor=blue!60]{1,2,1,1.7,1.3,3}
\psKiviatLine[linewidth=2pt,linecolor=red!60]{2.25,2.5,0.6,1.2,1,1}
\multido{\rA=0.5+0.5,\iA=10+10}{6}{\uput[3](0,\rA){\$\iA}}
\end{pspicture}}

\clearpage
\begin{pspicture}(-5,-5)(5,5)
\psKiviat[fillstyle=solid,fillcolor=red!20,
  yLabels={McCabe,LOC,Live Variables,Halstead N,Variablenspanne},
  labelsep=20pt]{5}{4}
\psKiviatLine[fillstyle=solid,fillcolor=white]{3,3.5,3,3.5,3}
\psKiviatLine[fillstyle=solid,fillcolor=black!10]{0.5,1,0.5,0.75,1}
\psKiviatLine[dotstyle=square*,linewidth=1.5pt,linecolor=red]{2,3.75,1,1.5,2}
\psKiviatTicklines[Dx=0.5,subtickcolor=black!15]{5}{4}
\psKiviatAxes[arrows=->,arrowscale=2]{5}{4.5}
\end{pspicture}

\end{document}

enter image description here enter image description here

share|improve this answer
    
thanks, on page 9 there is an example i'm looking for. the values wouldnt matter. books.google.com/… –  adnc Feb 1 '11 at 22:51
    
@adnc: I added an example. Run it with xetex or load package auto-pst-pdf and run it with pdflatex -shell-escape file –  Herbert Feb 2 '11 at 9:33
    
Unfortunately I can't get it compile. It hangs on a "Undefined control sequence" ! Undefined control sequence. \resetOptions ...\pst@linetype {0}\pstScalePoints (1,1){}{}\psset [pstricks-... l.2277 \resetOptions –  adnc Feb 2 '11 at 19:43
1  
@adnc: maybe that I did sonwething wrong, but this version http://texnik.dante.de/tex/generic/pstricks/pstricks.tex has it. Put also \listfiles as first line into the document, then you'll get a list of all loaded files at the end of the log file. –  Herbert Feb 2 '11 at 21:15
1  
@adnc: when you want to rotate the diagram use rotate=<angle>. But you have to remember that the whole circle has 6 degrees in the first and 5 degrees in the second example. The reason why I used rotate=0.5 in the first example, which is the same as 30 degrees for a 360° circle –  Herbert Feb 2 '11 at 21:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.