TiKz Kiviat 多图表

TiKz Kiviat 多图表

我正在尝试创建一个多图表,以显示多个 kiviat 图的“层次结构”。

下面我展示的是预期的图片。有人能帮助我吗?

在此处输入图片描述

一个 kiviat 的代码如下。

\documentclass{article}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}
\usepackage{tkz-kiviat,numprint,fullpage}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\newcommand\ColorBox[1]{\textcolor{#1}{\rule{2ex}{2ex}}}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}  
\usepackage{etoolbox}
\usetikzlibrary{calc} 

\begin{document}

\makeatletter
\patchcmd{\tkz@KiviatGrad}{\pgfmathresult}{\pgfmathresult/10}
         {\typeout{*** SUCCESS ***}}
         {\ERRORpatchfailed}
\makeatother 
\begin{figure}[!h]
\centering
\frame{
\begin{tikzpicture}[label distance=.15cm, scale=0.5]
 \tkzKiviatDiagram[radial  style/.style ={-}, lattice style/.style ={black!30}]% 
{$Q_u$, $Q_c$, $Q_d$, $Q_{da}$, $Q_m$, $Q_p$, $Q_t$}
 \tkzKiviatLine[thick,color=red!20,
                mark=ball,
                ball color=red!20,
                mark size=4pt,
                fill=red!20](8,7.5,10,10,9,9,7.5)
 \tkzKiviatLine[thick,color=blue!20,mark=ball,
                mark size=4pt,
                mark color=blue!20,
                fill=blue!20,
                opacity=.5](8.6,9,10,10,8,5,5)


  \tkzKiviatGrad[suffix=,unity=1](0)


\end{tikzpicture}}

\end{figure}
\end{document}

答案1

一种可能性是将每个图表放在一个范围内,例如

\begin{scope}[local bounding box=a,shift={(10,10)}]
  % diagram
\end{scope}

需要根据图表的大小进行调整。您可以使用(此处)shift的名称作为节点名称,并在它们之间画线。local bounding boxa

\documentclass{article}
\usepackage{tkz-kiviat,pgfplots}

%just for example
\usepackage{geometry}
\geometry{margin=1cm}

\makeatletter
\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 {1,...,\tkz@kiv@lattice}{
 \pgfmathparse{\tkz@kiv@unity*\nv} 
 \pgfmathsetmacro{\result}{\pgfmathresult} % change from \pgfmathtruncatemacro
 \protected@edef\tkz@kiv@gd{\tkz@kiv@prefix\pgfmathprintnumber[precision=1,fixed]{\result}\tkz@kiv@suffix} % used \pgfmathprintnumber instead of "$\result$"
    \path[/kiviatgrad/.cd,#1] (0:0)--(360/\tkz@kiv@radial*#2:\nv*\tkz@kiv@gap) 
       node[label=(360/\tkz@kiv@radial*#2)-90:\tiny\tkz@kiv@gd] {}; % added \tiny
      }
 \let\tikz@label@distance\tikz@label@distance@tmp  
\endgroup
}%
\makeatother
\begin{document}

\begin{figure}[!h]
\centering
\begin{tikzpicture}[label distance=.15cm,scale=0.4]

\begin{scope}[local bounding box=a]
 \tkzKiviatDiagram[radial  style/.style ={-}, lattice style/.style ={black!30}]% 
{$Q_u$, $Q_c$, $Q_d$, $Q_{da}$, $Q_m$, $Q_p$, $Q_t$}
\tkzKiviatLine[thick,color=red!20,
                mark=ball,
                ball color=red!20,
                mark size=4pt,
                fill=red!20](8,7.5,10,10,9,9,7.5)
 \tkzKiviatLine[thick,color=blue!20,mark=ball,
                mark size=4pt,
                mark color=blue!20,
                fill=blue!20,
                opacity=.5](8.6,9,10,10,8,5,5)
\tkzKiviatGrad[unity=0.1](1) % set unity as 0.1
\end{scope}

\begin{scope}[local bounding box=b,shift={(-15,-15)}]
 \tkzKiviatDiagram[radial  style/.style ={-}, lattice style/.style ={black!30}]% 
{$Q_u$, $Q_c$, $Q_d$, $Q_{da}$, $Q_m$, $Q_p$, $Q_t$}
\tkzKiviatLine[thick,color=red!20,
                mark=ball,
                ball color=red!20,
                mark size=4pt,
                fill=red!20](8,7.5,10,10,9,9,7.5)
 \tkzKiviatLine[thick,color=blue!20,mark=ball,
                mark size=4pt,
                mark color=blue!20,
                fill=blue!20,
                opacity=.5](8.6,9,10,10,8,5,5)
\tkzKiviatGrad[unity=0.1](1) % set unity as 0.1
\end{scope}

\begin{scope}[local bounding box=c,shift={(15,-15)}]
 \tkzKiviatDiagram[radial  style/.style ={-}, lattice style/.style ={black!30}]% 
{$Q_u$, $Q_c$, $Q_d$, $Q_{da}$, $Q_m$, $Q_p$, $Q_t$}
\tkzKiviatLine[thick,color=red!20,
                mark=ball,
                ball color=red!20,
                mark size=4pt,
                fill=red!20](8,7.5,10,10,9,9,7.5)
 \tkzKiviatLine[thick,color=blue!20,mark=ball,
                mark size=4pt,
                mark color=blue!20,
                fill=blue!20,
                opacity=.5](8.6,9,10,10,8,5,5)
\tkzKiviatGrad[unity=0.1](1) % set unity as 0.1
\end{scope}


\draw [shorten <=-1cm,shorten >=-1cm] (a) -- (b);
\draw [shorten <=-1cm,shorten >=-1cm] (a) -- (c);
\end{tikzpicture}
\end{figure}
\end{document}

相关内容