41

This question led to a new package:
tkz-kiviat

Is there a way to draw Kiviat diagrams easily?

Sample Kiviat diagram

Bobyandbob
  • 4,899
adnc
  • 1,746
  • these are both rich answers! thank you very much for your help – adnc Feb 02 '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 02 '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 02 '11 at 14:55

3 Answers3

35

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

doncherry
  • 54,637
Alain Matthes
  • 95,075
  • unfortunately I do get an ! Undefined control sequence. 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 07 '11 at 19:49
  • @adnc I made it with pgf 2.1 This is the new version of pgf – Alain Matthes Feb 07 '11 at 20:25
  • @adnc you can get pgf 2.1 here http://sourceforge.net/projects/pgf/ and you can install it in your texmf. – Alain Matthes Feb 07 '11 at 20:34
  • I again need to say that this solution is great! – adnc Jun 28 '11 at 09:25
  • @doncherry Yes I created this package for this question – Alain Matthes Apr 04 '13 at 19:43
  • Unforunately, the arrows seem to draw to the center of the text rather than edge. This is visible when you use longer text for the labels. For example, try \begin{tikzpicture}\tkzKiviatDiagram[gap=.25,label space=.75]{Long text,Long text,Long text,Long text,Long text}\end{tikzpicture} – me-- Jun 12 '19 at 10:37
  • It's also pretty visible in the example screenshots above. The labels on the vertical axis are further away from the arrow than the labels on the horizontal. – me-- Jun 12 '19 at 10:47
  • Just a comment to report a deadlink on your personal website – UserK Nov 05 '19 at 09:51
  • @AlainMatthes - how to add a legend for each coloured line? There's no note of this in the docs. Highly useful CTAN package btw, thanks. – pds Dec 23 '19 at 04:43
  • @pdsI made this package 8 years ago and I have never seen the code since ... ! But no you can't add legend with it. You need to use TikZ to do the legend. I don't have enough time to help you because I have to finish another package quickly. Ask a question about this ... (Some examples of the documentation have some problem with pgf >3 ) – Alain Matthes Dec 23 '19 at 05:21
  • @pds I finish tkz-euclide and I look to answer ... – Alain Matthes Dec 23 '19 at 05:23
  • Thanks for reply @AlainMatthes, I understand. This excerpt serves my purpose, but it's not responsive to label length variations. Please feel free to use/modify. \renewcommand{\tkzKiviatLegend}[2]{\begin{tikzpicture} \draw[draw=black!05] (-0.1,-0.2) rectangle ++(6.25,0.5); \draw [thick, blue] (0,0) -- (1,0); \node at (2.15,0) {#2}; \draw [thick, green] (3.25,0) -- (4.25,0); \node at (5.25,0) {#1}; \end{tikzpicture}} – pds Dec 23 '19 at 09:34
  • Your linked homepage seems to be down. – dexteritas Apr 14 '20 at 17:01
  • 1
    @dexteritas yes altermundus.com is closed. I'll put some examples on http://altermundus.fr in a while but I have to update the package first. I don't have the time now. – Alain Matthes Apr 14 '20 at 19:19
  • @Alain Matthes: Sadly your package is out of TEXLive, I had to install it manually. – Thomas Benko Mar 23 '23 at 20:17
  • @ThomasBenko yes you are right and I'm sorry but I don't have time to do it and I'm currently only working on tkz-euclide. I haven't used it for more than 10 years and I don't even know if it is still compatible with the new versions of pgf. – Alain Matthes Mar 24 '23 at 09:54
  • @Alain Matthes: The compatibility is a little borderlined. (And as a math theacher, I'm happy to know, you are working on tkz-euclide, I use that pack very heavily.) – Thomas Benko May 21 '23 at 10:37
19

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

romeovs
  • 9,102
  • this is really good, except i would need to plot one dataset and also a toleranceband – adnc Feb 01 '11 at 22:49
  • is this a one time deal or do you need a macro that will be used several times? – romeovs Feb 01 '11 at 22:53
  • I'll need to produce these diagrams several times. – adnc Feb 01 '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 01 '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 01 '11 at 23:20
14

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

  • thanks, on page 9 there is an example i'm looking for. the values wouldnt matter. http://books.google.com/books?id=mUTtO9HhTX0C&pg=PA9&lpg=PA9&dq=kiviat+diagramm+metrik&source=bl&ots=JjkfmaxNEU&sig=-rzrZEkvZxGRkQbt3CgtvVV-j7s&hl=de&ei=O45ITf-CD8nCswauhKGMAw&sa=X&oi=book_result&ct=result&resnum=2&ved=0CBwQ6AEwAQ#v=onepage&q=kiviat%20diagramm%20metrik&f=false – adnc Feb 01 '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 –  Feb 02 '11 at 09: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 02 '11 at 19:43
  • @adnc: what TeX distribution do you have installed and what operatinf system are you running? –  Feb 02 '11 at 19:44
  • @herbert I'm running Ubuntu 10.10 and TeX Live – adnc Feb 02 '11 at 20:08
  • @adnc: ok, if it is the TeX Live from Ubuntu it is really out of date. Go to http://texnik.dante.de, there is a link for a complete tarzip of all pstricks files. They are always in the correct directories, which should also on ubuntu at ???/texlive-texmf/ or something else. After running texhash your pstricks system is up to date. –  Feb 02 '11 at 20:15
  • @herbert I'm facing this problem now ! Undefined control sequence. \psKiviat@i ...e \def \pst@Coordinates {} \psLoop {#1}{\xdef \pst@Coordinate... l.12 labelsep=20pt]{5}{4} although \psKiviat is available in the pstricks-add.tex – adnc Feb 02 '11 at 20:38
  • @adnc: yes, but you didn't have the newest pstricks.tex. It defines the \psLoop macro –  Feb 02 '11 at 20:44
  • @herbert I downloaded http://archiv.dante.de/~herbert/PSTricks-TDS.tgz and installed it as you suggested. But \psLoop is not defined inside. So where can I take it from? – adnc Feb 02 '11 at 21:00
  • 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. –  Feb 02 '11 at 21:15
  • @herbert, yes thats it! Great work, thank you very much. – adnc Feb 02 '11 at 21:24
  • 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 –  Feb 02 '11 at 21:27