我想制作一个类似这样的生命之轮:
我曾尝试使用 tikz 制作一个;但是我陷入了
- 我希望“职业”这样的名称与圆的周长对齐
- 我希望数学(比例)对于内部形状(圆圈)从 1 到 10 是正确的。在我的代码中,我使用诸如 之类的东西
\angle*1:\mybf+.1012cm*\mcf
。我希望 的值为\mybf+.1012cm*\mcf
1、2、3 等。 - 显示值(数字)1、2、3 等
请看我做的。我使用了很多\def
已定义的变量,我相信专家会做得更简单、更容易。
最后,这是我的代码:
\documentclass[12pt]{article}
\usepackage[landscape]{geometry}
\usepackage{tikz}
\definecolor{forestgreen}{RGB}{60,127,50}
\definecolor{mahogany}{RGB}{169,52,72}
\definecolor{insightly}{RGB}{255,74,0}
\definecolor{minbelow}{RGB}{167,116,16}
\def\mybf{.55cm}
\def\radiusf{\mybf}
\def\mcf{.55cm}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
\draw[red] (0,0) circle (8cm);
\node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
\foreach \x [count=\xi] in {360, 315, ..., 45}
{
\draw[thin, gray!40] (a) -- (\x:\radiusf+212);
}
\def\shi{255};
\draw (360:\radiusf+\shi) node {Health};
\draw (315:\radiusf+\shi) node {Spritual};
\draw (270:\radiusf+\shi) node {Career};
\draw (225:\radiusf+\shi) node {Financial};
\draw (180:\radiusf+\shi) node {Friends \& Family};
\draw (135:\radiusf+\shi) node {Personal Growth};
\draw (90:\radiusf+\shi) node {Romance};
\draw (45:\radiusf+\shi) node {Entetainment};
\def\angle{360/8};
\draw[mahogany] (\mybf+.1090cm*\mcf,0) -- (\angle*1:\mybf+.1012cm*\mcf) -- (\angle*2:0.235cm*\mcf) -- (\angle*3:\mybf+.0898cm*\mcf) -- (\angle*4:\mybf+.0918cm*\mcf)-- (\angle*5:\mybf+.0906cm*\mcf)-- (\angle*6:\mybf+.0963cm*\mcf) -- (\angle*7:\mybf+.1018cm*\mcf) -- (\angle*8:\mybf+.1025cm*\mcf) -- (\mybf+.1090cm*\mcf,0);
\end{tikzpicture}
\end{document}
答案1
这是一个非常有趣的挑战,这里有一个制作第一个图形的谜题,我创建了一个名为的函数\lifeweel
,第一个参数表示级别,第二个参数表示网格,第三个参数表示特征的数量,第四个参数是一个构造,其中包含每个字符的名称和具体值。
更新:使用范围允许绘制多个图形,创建第二个智能对象代码,称为\lifeweelS
意味着您可以通过\lifeweel
添加“S”来转换对象,这将创建另一种类型的生命之轮。操作码\lifeweel{levels}{grid}{number of features}{feature_name/quantity}[anchor angle][numbers direction in degrees][relative position](ID);
结果:
MWE?:
% arara: pdflatex: {synctex: yes, action: nonstopmode}
% By J. Leon V. Share as Beerware philosophy
\documentclass[border=20pt]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{pgfmath}
\usepackage{xifthen}
\usetikzlibrary{decorations.text, arrows.meta,calc,shadows.blur,shadings}
\renewcommand*\familydefault{\sfdefault} % Set font to serif family
\begin{document}
\begin{tikzpicture}[
% Environment Cfg
font=\Large,
scale=1,
% Styles
Grid/.style={
loosely dotted,
line width=1.5pt,
color=black
},
Separator/.style={
thick,
color=black!50
},
Border/.style={
line width=1pt,
color=red!60
},
Border2/.style={
line width=2pt,
color=red!60
},
Fill/.style={
fill=black,
opacity=0.1
}
]
% lifeweel from many codes arround TEX.SE
%Variables: 1:levels, 2:grid 3:number of features 4: Feature_name/quantity
% 5: anchor aling 6: numbers position 7:Relative position 8:ID
\def\lifeweel#1#2#3#4[#5][#6](#7)(#8){%
\begin{scope}[shift={(#7)}]
%Decoration
\foreach \n in {0,#2,...,#1}{
\draw[fill=black, opacity=0.1] (0,0) circle [radius=\n];}
%Drawing the grid and numbers.
\foreach \n in {0,#2,...,#1}{
\draw[Grid] (0,0) circle [radius=\n];
\node[anchor=#5] (A) at (#6:\n+0.2){\n};}
%Drawing features separations.
\foreach \m [count=\i] in {0,1,...,#3}{
\draw[Separator] (0,0) -- (360/#3*\i: #1);}
%Drawing the border
\draw[Border] (0,0) circle [radius=#1];
%Drawing the names
\foreach \o/\p [count=\j] in {#4}{
\pgfmathparse{int(360/#3*\j)}
\ifthenelse{ \pgfmathresult >180}
{% True
\path[%Reverse
decoration={
raise = -0.8ex,
text along path,
text = {|\huge|\o},
text align = center,
reverse path
},
decorate
]
(360/#3*\j:#1+0.7) arc (360/#3*\j:360/#3*(\j-1):#1+0.7);%\path
}
{%False
\path[%Normal
decoration={
raise = -0.8ex,
text along path,
text = {|\huge|\o},
text align = center
},
decorate
]
(360/#3*\j:#1+0.7) arc (360/#3*\j:360/#3*(\j-1):#1+0.7); %Path
}
\draw[Border2]
(360/#3*\j:\p) coordinate (#8a\j)
arc (360/#3*\j:360/#3*(\j-1):\p) coordinate (#8b\j);
\draw[fill=red, opacity=0.2]
(0,0) -- (360/#3*\j:\p) arc (360/#3*\j:360/#3*(\j-1):\p);
}
\pgfmathparse{int(#3+1)} % Principle of uroboro
\coordinate (#8b\pgfmathresult) at (#8b1);
\foreach \o/\p [count=\i, evaluate=\i as \x using int(\i+1)] in {#4}{%Close the perimete
\draw[Border2] (#8a\i) -- (#8b\x);}
\end{scope}
}
%Variables: 1:levels, 2:grid 3:number of features 4: Feature_name/quantity
% 5: anchor aling 6: numbers position 7:Relative position 8: ID
\def\lifeweelS#1#2#3#4[#5][#6](#7)(#8){%
\begin{scope}[shift={(#7)}]
%Drawing the numbers.
\foreach \n [count=\m] in {0,#2,...,#1}{
\node[anchor=#5] (A) at (#6:\n+0.2){\n};
}
%Drawing the grid
\foreach \n in {0,#2,...,#1}{
\foreach [count=\i, evaluate=\i as \x using int(\i+1)]\m in {0,1,...,#3}{
\draw[Grid](360/#3*\i:\n) -- (360/#3*\x:\n);
\draw[Fill](360/#3*\i:\n) -- (0,0) -- (360/#3*\x:\n);
}
}
%Drawing features separations.
\foreach \m [count=\i] in {0,1,...,#3}{
\draw[Separator] (0,0) -- (360/#3*\i: #1);}
%Drawing the border
\draw[fill=black, opacity=0.1] (0,0) circle [radius=#1];
\draw[Border] (0,0) circle [radius=#1];
%Drawing the names
\foreach \o/\p [count=\j from 0] in {#4}{
\pgfmathparse{int(360/#3*\j)}
\ifthenelse{\pgfmathresult =90 \OR \pgfmathresult =270}
{%True
\draw (360/#3*\j:#1+0.7) node [anchor=center]{\huge\o};
}
{%false
\ifthenelse{\pgfmathresult <90 \OR \pgfmathresult >270}
{% True
\draw (360/#3*\j:#1+0.7) node [anchor=west]{\huge\o};
}
{%False
\draw (360/#3*\j:#1+0.7) node [anchor=east]{\huge\o};
}
}
\coordinate (#8c\j) at (360/#3*\j:\p);
}
\coordinate (#8c#3) at (#8c0);
\foreach \o/\p [count=\i from 0, evaluate=\i as \x using int(\i+1)] in {#4}{%Close the perimete
\draw[Border2] (#8c\i) -- (#8c\x);
\draw[fill=red, opacity=.2] (#8c\i) --(0,0) -- (#8c\x);
}
\end{scope}
}
% This function draws the lifeweel
%\lifeweel{levels}{grid}{number of features}{feature_name/quantity}[anchor angle][numbers direction in degrees][relative position](ID);
\lifeweel{10}{2}{8}{
Money/5,
Entertainment/4,
Romance/7,
Presonal Growth/9,
Friends {\&} Family/3,
Financial/5,
Spiritual/7,
Health/5
}[45][180](0,0)(1);
\lifeweel{10}{1}{5}{
Money/5,
Entertainment/3,
Romance/8,
Presonal Growth/6,
Friends {\&} Family/8
}[-90][0](25,0)(2);
\lifeweelS{10}{2}{8}{
Money/5,
Entertainment/4,
Romance/7,
Presonal Growth/9,
Friends {\&} Family/3,
Financial/5,
Spiritual/7,
Health/5
}[45][180](0,-25)(3);
\lifeweelS{10}{1}{5}{
Money/5,
Entertainment/3,
Romance/8,
Presonal Growth/6,
Friends {\&} Family/8
}[-90][0](25,-25)(4);
\end{tikzpicture}
\end{document}
PSD:代码可以让你达到这些极端,虽然它有点暗(不太容易阅读),但我认为你可以玩所有的选项,当然达到这些极端只是为了好玩并创建一个有用的 tikz 框架。
答案2
我有一个“最小损害建议”,因为我不明白为什么你使用landscape
和article
而不是standalone
。请注意,无量纲长度被解释为pt
。我使用锚将东西放在靠近圆圈的地方。
\documentclass[12pt]{article}
\usepackage[landscape]{geometry}
\usepackage{tikz}
\definecolor{forestgreen}{RGB}{60,127,50}
\definecolor{mahogany}{RGB}{169,52,72}
\definecolor{insightly}{RGB}{255,74,0}
\definecolor{minbelow}{RGB}{167,116,16}
\def\mybf{.55cm}
\def\radiusf{8cm}
\def\mcf{.55cm}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
\draw[red] (0,0) circle (\radiusf);
\node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
\foreach \x [count=\xi] in {360, 315, ..., 45}
{
\draw[thin, gray!40] (a) -- (\x:\radiusf);
}
\foreach \X in {1,...,9} {
\draw[dashed,gray] (0,0) circle ({\radiusf*\X/10});
\node[above left] at (180:{\radiusf*\X/10}){\X};
}
\def\shi{2pt};
\draw (360:\radiusf+\shi) node[anchor=west] {Health};
\draw (315:\radiusf+\shi) node[anchor=north west] {Spritual};
\draw (270:\radiusf+\shi) node[anchor=north] {Career};
\draw (225:\radiusf+\shi) node[anchor=north east] {Financial};
\draw (180:\radiusf+\shi) node[anchor=east] {Friends \& Family};
\draw (135:\radiusf+\shi) node[anchor=south east] {Personal Growth};
\draw (90:\radiusf+\shi) node[anchor=south] {Romance};
\draw (45:\radiusf+\shi) node[anchor=south west] {Entertainment};
\def\angle{360/8};
\draw[mahogany,thick]
\foreach \X [count=\Y] in {1,2,1,3,2,1,2,3}
{\ifnum\Y>1
--
\else
\pgfextra{\xdef\Xstart{\X}}
\fi
({\angle*\Y}:{\radiusf*\X/10}) arc({\angle*\Y}:{\angle*(\Y+1)}:{\radiusf*\X/10})
}
--(\angle:{\radiusf*\Xstart/10});
\end{tikzpicture}
\end{document}
更新:添加数字并简化桃花心木曲线。