# How to change the grad scale values with tkzKiviatDiagram?

Is it possible to change the tkzKiviatGrad scale that it starts with -2 instead of 0? So the sale in the bellow example would be -2 -1 0 1 2.

Also, can I display the starting point in center of the graph somehow?

\documentclass{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{tkz-kiviat}
\usetikzlibrary{arrows,positioning,fit}
\begin{document}

\begin{figure}[h!]
\centering
\begin{tikzpicture}
\tkzKiviatDiagram[scale=0.8,label distance=1cm,
gap     = 1.5,
lattice = 4]{Barfoo1,Barfoo2,Barfoo3,Barfoo4,Barfoo5,Barfoo6}
\tkzKiviatLine[thick,color=blue](1,2,3,2,4,0)
\tkzKiviatLine[thick,color=yellow](1,2,4,1,4,2)
\tkzKiviatLine[thick,color=green](1,4,4,2,4,4)
\tkzKiviatLine[thick,color=Aquamarine](1,2,3,1,2,2)
\tkzKiviatLine[thick,color=Magenta](1,3,4,1,4,3)
\node[anchor=south west,xshift=-60pt,yshift=40pt] at (current bounding box.south east)
{
\begin{tabular}{@{}lp{4cm}@{}}
\cellcolor{blue} & Foobar1 \\
\cellcolor{yellow} & Foobar2 \\
\cellcolor{green} & Foobar3\\
\cellcolor{Aquamarine} & Foobar4 \\
\cellcolor{Magenta} & Foobar5 \\
\end{tabular}
};
\end{tikzpicture}
\end{figure}

\end{document}


To solve the problem have a look to tkz-kiviat.sty and the definition of \tkzKiviatGrad.

Result:

MWE:

\documentclass{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{tkz-kiviat}
\usetikzlibrary{arrows}

\makeatletter
\begingroup
prefix ={},
suffix={},
unity=1
}
\let\tikz@label@distance@tmp\tikz@label@distance
\foreach \nv in {0,...,\tkz@kiv@lattice}{ %original: \foreach \nv in {1,...,\tkz@kiv@lattice}{
\pgfmathparse{\tkz@kiv@unity*\nv}
\pgfmathtruncatemacro{\result}{\pgfmathresult-2} %original: \pgfmathtruncatemacro{\result}{\pgfmathresult}
\protected@edef\tkz@kiv@gd{\tkz@kiv@prefix$\result$\tkz@kiv@suffix}
}
\let\tikz@label@distance\tikz@label@distance@tmp
\endgroup
}%
\makeatother

% \usepackage{etoolbox}
% \makeatletter
%          {\typeout{*** SUCCESS ***}}
%          {\ERRORpatchfailed}
% \makeatother

\begin{document}

\begin{figure}[h!]
\centering
\begin{tikzpicture}
\tkzKiviatDiagram[scale=0.8,label distance=1cm,
gap     = 1.5,
lattice = 4]{Barfoo1,Barfoo2,Barfoo3,Barfoo4,Barfoo5,Barfoo6}
\tkzKiviatLine[thick,color=blue](1,2,3,2,4,0)
\tkzKiviatLine[thick,color=yellow](1,2,4,1,4,2)
\tkzKiviatLine[thick,color=green](1,4,4,2,4,4)
\tkzKiviatLine[thick,color=Aquamarine](1,2,3,1,2,2)
\tkzKiviatLine[thick,color=Magenta](1,3,4,1,4,3)

\node[anchor=south west,xshift=-60pt,yshift=40pt] at (current bounding box.south east)
{
\begin{tabular}{@{}lp{4cm}@{}}
\cellcolor{blue} & Foobar1 \\
\cellcolor{yellow} & Foobar2 \\
\cellcolor{green} & Foobar3\\
\cellcolor{Aquamarine} & Foobar4 \\
\cellcolor{Magenta} & Foobar5 \\
\end{tabular}
};
\end{tikzpicture}
\end{figure}

\end{document}


1. How to change only the grad scale values? (solves only problem 1)

You could use \patchcmd with \usepackage{etoolbox} to redefine a command inside .sty file. You have to surround your redefinition with \makeatletter and \makeatother in order to be able to access or modify commands that contain an @ sign in their names. (Ref.:@Frank Mittelbach s approach:Modifying .sty files?

For shifting your scale from 0 1 2 3 4 to -2 -1 0 1 2 you have to subtract 2 ( from computed value of \pgfmathparse inside the \def\tkz@KiviatGrad definition ) with the redefinition below:

\usepackage{etoolbox}
\makeatletter
{\typeout{*** SUCCESS ***}}
{\ERRORpatchfailed}
\makeatother


2. Display the starting point in center (solves problem 1 and 2)

For the second question i only found the solution to redefine the whole definiton. Because the for-loop with variable \nv has to start with 0 istead of 1 so add the following to your preamble. To solve also problem 1 the same way replace \pgfmathtruncatemacro{\result}{\pgfmathresult} with \pgfmathtruncatemacro{\result}{\pgfmathresult-2}. : (Ref.:@Werner s approach :local redefinition with \makeatletter ... \makeatother

\makeatletter
\begingroup
prefix ={},
suffix={},
unity=1
}
\let\tikz@label@distance@tmp\tikz@label@distance
\foreach \nv in {0,...,\tkz@kiv@lattice}{ %original: \foreach \nv in {1,...,\tkz@kiv@lattice}{
\pgfmathparse{\tkz@kiv@unity*\nv}
\pgfmathtruncatemacro{\result}{\pgfmathresult-2} %original: \pgfmathtruncatemacro{\result}{\pgfmathresult}
\protected@edef\tkz@kiv@gd{\tkz@kiv@prefix$\result$\tkz@kiv@suffix}
}
\let\tikz@label@distance\tikz@label@distance@tmp
\endgroup
}%
\makeatother