我正在写一篇论文,其双极结果范围从 -3 到 3,但不包括 0。我怎样才能跳过它。我已经在序言中使用了一些东西将数字向下移动 3 位以实现 -3 开始。MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[normalem]{ulem}
\useunder{\uline}{\ul}{}
\usepackage{pdfpages}
\usepackage[margin=1in]{geometry}
\usepackage{tkz-kiviat}
\usepackage{float}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage[export]{adjustbox}
\usepackage{tikzscale}
\usetikzlibrary{arrows}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\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-3} %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
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[rotate=45]
\tkzKiviatDiagram[scale=.6,label distance=.5cm, radial=5,
gap=1, lattice=5,label space=2.5]{Vulnerability to erosion,Vulnerability to overtopping,Aesthetic value,Ease of beach access,Safety factor,Lifespan,Disruption to local residents during construction,Disruption to natural coastal processed and habitats}
\tkzKiviatLine[ultra thick,color=red,mark=none,fill=red,opacity=.2](0,2,3,4,5,5,4,2)
\tkzKiviatGrad[unity=1](0)
\end{tikzpicture}
\caption{Kiviat chart showing the evaluation of rip rap as a management strategy}
\label{fig:radar_rr}
\end{figure}
\end{document}
答案1
这就是你所说的“跳过 0”的意思吗?
\documentclass[tikz,border=3.14mm]{standalone}
\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}{ifthenelse(\pgfmathresult<3,\pgfmathresult-3,\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
\begin{document}
\begin{tikzpicture}[rotate=45]
\tkzKiviatDiagram[scale=.6,label distance=.5cm, radial=5,
gap=1, lattice=5,label space=2.5]{Vulnerability to erosion,Vulnerability to overtopping,Aesthetic value,Ease of beach access,Safety factor,Lifespan,Disruption to local residents during construction,Disruption to natural coastal processed and habitats}
\tkzKiviatLine[ultra thick,color=red,mark=none,fill=red,opacity=.2](0,2,3,4,5,5,4,2)
\tkzKiviatGrad[unity=1](0)
\end{tikzpicture}
\end{document}