¿Cómo cambiar los valores de la escala de graduación con tkzKiviatDiagram?

¿Cómo cambiar los valores de la escala de graduación con tkzKiviatDiagram?

¿Es posible cambiar la escala tkzKiviatGrad para que comience con -2 en lugar de 0? Entonces, la venta en el siguiente ejemplo sería -2 -1 0 1 2.

Además, ¿puedo mostrar de alguna manera el punto inicial en el centro del gráfico?

\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)
\tkzKiviatGrad[unity=1](0)
\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}

Respuesta1

Para solucionar el problema echa un vistazo atkz-kiviat.styy la definición de \tkzKiviatGrad.

Resultado:

ingrese la descripción de la imagen aquí

MWE:

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

\makeatletter
\def\tkzKiviatGrad{\pgfutil@ifnextchar[{\tkz@KiviatGrad}{\tkz@KiviatGrad[]}} 
\def\tkz@KiviatGrad[#1](#2){% 
\begingroup
\pgfkeys{/kiviatgrad/.cd,
graduation distance= 0 pt,
prefix ={},
suffix={},
unity=1
 }
 \pgfqkeys{/kiviatgrad}{#1}% 
\let\tikz@label@distance@tmp\tikz@label@distance
\global\let\tikz@label@distance\tkz@kiv@grad
 \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}
    \path[/kiviatgrad/.cd,#1] (0:0)--(360/\tkz@kiv@radial*#2:\nv*\tkz@kiv@gap) 
       node[label=(360/\tkz@kiv@radial*#2)-90:\tkz@kiv@gd] {}; 
      }
 \let\tikz@label@distance\tikz@label@distance@tmp  
\endgroup
}%
\makeatother

 % \usepackage{etoolbox}
% \makeatletter
% \patchcmd{\tkz@KiviatGrad}{\pgfmathresult}{\pgfmathresult-2}
%          {\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)
\tkzKiviatGrad[unity=1](0)

\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. ¿Cómo cambiar solo los valores de la escala de graduación?(sólo resuelve el problema 1)

Podrías usar \patchcmdwith \usepackage{etoolbox}para redefinir un comando dentro .stydel archivo. Debe rodear su redefinición con \makeatlettery \makeatotherpara poder acceder o modificar comandos que contienen un signo @ en sus nombres. (Árbitro.:Enfoque de @Frank Mittelbach: ¿Modificar archivos .sty?

Para cambiar su escala de 0 1 2 3 4a, -2 -1 0 1 2debe restar 2(del valor calculado de \pgfmathparsedentro de la \def\tkz@KiviatGraddefinición) con la siguiente redefinición:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\tkz@KiviatGrad}{\pgfmathresult}{\pgfmathresult-2}
         {\typeout{*** SUCCESS ***}}
         {\ERRORpatchfailed}
\makeatother 

2. Muestra el punto de partida en el centro.(resuelve los problemas 1 y 2)

Para la segunda pregunta solo encontré la solución para redefinir toda la definición. Debido a que la for-loopvariable with \nvtiene que comenzar con 0i en lugar de 1, agregue lo siguiente a su preámbulo. Para resolver también el problema 1 de la misma manera, reemplácelo \pgfmathtruncatemacro{\result}{\pgfmathresult}con \pgfmathtruncatemacro{\result}{\pgfmathresult-2}. : (Ref.:Enfoque de @Werner: redefinición local con \makeatletter ... \makeatother

\makeatletter
\def\tkzKiviatGrad{\pgfutil@ifnextchar[{\tkz@KiviatGrad}{\tkz@KiviatGrad[]}} 
\def\tkz@KiviatGrad[#1](#2){% 
\begingroup
\pgfkeys{/kiviatgrad/.cd,
graduation distance= 0 pt,
prefix ={},
suffix={},
unity=1
 }
 \pgfqkeys{/kiviatgrad}{#1}% 
\let\tikz@label@distance@tmp\tikz@label@distance
\global\let\tikz@label@distance\tkz@kiv@grad
 \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}
    \path[/kiviatgrad/.cd,#1] (0:0)--(360/\tkz@kiv@radial*#2:\nv*\tkz@kiv@gap) 
       node[label=(360/\tkz@kiv@radial*#2)-90:\tkz@kiv@gd] {}; 
      }
 \let\tikz@label@distance\tikz@label@distance@tmp  
\endgroup
}%
\makeatother

información relacionada