大家好,
我尝试绘制哈斯图(如上图),但我不知道。
感谢您的帮助。
\documentclass[tikz,12pt]{standalone}
\begin{document}
\begin{tikzpicture}
\fill [gray] (90:2) arc[start angle=90, end angle =210, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\begin{tikzpicture}
\fill [gray] (210:2) arc[start angle=210, end angle =330, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\begin{tikzpicture}
\fill [gray] (330:2) arc[start angle=-30, end angle =90, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\begin{tikzpicture}
\fill [gray] (90:2) arc[start angle=90, end angle =210, radius=2cm] -- (0,0) -- cycle;
\fill [gray] (210:2) arc[start angle=210, end angle =330, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\begin{tikzpicture}
\fill [gray] (90:2) arc[start angle=90, end angle =210, radius=2cm] -- (0,0) -- cycle;
\fill [gray] (330:2) arc[start angle=-30, end angle =90, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\begin{tikzpicture}
\fill [gray] (210:2) arc[start angle=210, end angle =330, radius=2cm] -- (0,0) -- cycle;
\fill [gray] (330:2) arc[start angle=-30, end angle =90, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\begin{tikzpicture}
\fill [gray] (90:2) arc[start angle=90, end angle =210, radius=2cm] -- (0,0) -- cycle;
\fill [gray] (210:2) arc[start angle=210, end angle =330, radius=2cm] -- (0,0) -- cycle;
\fill [gray] (330:2) arc[start angle=-30, end angle =90, radius=2cm] -- (0,0) -- cycle;
\draw (0,0) circle (2cm) (90:2)--(0,0) (210:2)--(0,0) (330:2)--(0,0);
\end{tikzpicture}
\end{document}
答案1
我相信你会得到一些关于 TikZ 的帮助,但在你等待的时候,这里有一个替代方法,使用元帖子。我已经把它打包好了,luamplib
所以你应该用它编译它,lualatex
或者弄清楚如何将它改编为普通的 MP 或pdflatex
+良好生产规范。
\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
% some points
x1 = x3 = x6 = 0; -x2 = -x5 = x4 = x7 = 80;
y2 = y3 = y4 = 0;
-y1 = y5 = y6 = y7 = 80;
% connect the dots
draw z1 -- z2 -- z5 -- z3 -- z7 -- z4 -- cycle;
draw z1 -- z3;
draw z2 -- z6 -- z4;
% routine to make a labelled node
vardef node(expr description, state) =
save p, c;
path c; c = fullcircle scaled 42;
picture p; p = image(
unfill c;
for i=-6 upto 6: draw (left--right) scaled 30 shifted (0,3i); endfor
clip currentpicture to c;
for i=1 upto 3:
if substring(i-1,i) of state = "0":
unfill origin -- subpath((6+8(i-1))/3,(6+8i)/3) of c -- cycle;
fi
endfor
for i=1 upto 3:
draw origin -- point (6+8i)/3 of c withpen pencircle scaled 3/4;
endfor
draw c withpen pencircle scaled 1;
label.lrt(description, point 6.25 of c);
);
p
enddef;
% mark each node ...
draw node("$T_1$", "111") shifted z1;
draw node("$T_2$", "110") shifted z2;
draw node("$T_3$", "101") shifted z3;
draw node("$T_4$", "011") shifted z4;
draw node("$T_5$", "100") shifted z5;
draw node("$T_6$", "010") shifted z6;
draw node("$T_7$", "001") shifted z7;
endfig;
\end{mplibcode}
\end{document}
答案2
您可以使用带有 的圆形节点path picture
来绘制和填充扇区。我创建了一个带有两个参数的样式,即起始角度和要覆盖的扇区数量。
\documentclass[tikz,12pt,border=5mm]{standalone}
\usetikzlibrary{positioning, patterns}
\begin{document}
\begin{tikzpicture}[
% modify the node distance to set the separation between circles
node distance=2cm,
hasse/.style 2 args={
CircleRad/.store in=\CircRad,
% change CircleRad to modify radius of circles
CircleRad=1cm,
circle,
draw,
thick,
minimum size=2*\CircRad,
path picture={
\pgfnodealias{BB}{path picture bounding box} % from https://tex.stackexchange.com/a/395641
\fill [pattern=horizontal lines] (BB.center) -- ++(#1:\CircRad) arc[radius=\CircRad,start angle=#1,delta angle=#2*120] -- cycle;
\draw (BB.center) -- (BB.90)
(BB.center) -- (BB.210)
(BB.center) -- (BB.330);
},
node contents={}
}
]
% first argument to hasse style is the start angle of the filled sector
% second argument is number of sectors to cover
\node [hasse={0}{3}, name=h1];
\node [hasse={330}{2}, name=h3, above=of h1];
\node [hasse={90}{2}, name=h2, left=of h3];
\node [hasse={210}{2}, name=h4, right=of h3];
\node [hasse={90}{1}, name=h6, above=of h3];
\node [hasse={210}{1}, name=h5, left=of h6];
\node [hasse={330}{1}, name=h7, right=of h6];
% draw connections
\foreach \x/\y in {1/2,1/3,1/4,2/5,2/6,3/5,3/7,4/6,4/7}
\draw (h\x) -- (h\y);
% add labels below circles
\foreach \h in {1,...,7}
\node [below=1mm,fill=white,inner sep=1pt,font=\footnotesize] at (h\h.south) {$T_{\h}$};
\end{tikzpicture}
\end{document}
答案3
一个pstricks
解决方案。基于该xstring
包,我定义了一个\ThreeSectors
命令,带有一个可选参数(之一W, S,E, SW, SE, WE
),它决定要孵化哪些扇区。
\documentclass[old, svgnames]{article}
\usepackage{pst-node, pst-poly, pst-eucl}%, auto-pst-pdf
\usepackage{xstring}
\newcommand\ThreeSectors[1][]{%
\PstTriangle[PolyName=A, linestyle=none]%\pscircle
\pstCircleOA{A0}{A1}
\psline(A2)(A0)(A1)(A0)(A3)
{\psset{fillstyle = hlines, hatchwidth = 0.5pt, hatchsep = 1.5pt, hatchcolor = LightSlateGray!80, hatchangle = 0}%
\IfStrEqCase{#1}{%
{S}{\pscustom{\psline(A0)(A2)\pstArcOAB{A0}{A2}{A3}\psline(A3)(A0)}}
{W}{\pscustom[hatchangle = 60]{\psline(A0)(A1)\pstArcOAB{A0}{A1}{A2}\psline(A2)(A0)}}
{E}{\pscustom[hatchangle =-60]{\psline(A0)(A1)\pstArcnOAB{A0}{A1}{A3}\psline(A3)(A0)}}
{SE}{\pscustom[hatchangle = 60]{\psline(A0)(A1)\pstArcnOAB{A0}{A1}{A2}\psline(A2)(A0)}}
{SW}{\pscustom[hatchangle = -60]{\psline(A0)(A1)\pstArcOAB{A0}{A1}{A3}\psline(A3)(A0)}}
{WE}{\pscustom{\psline(A0)(A3)\pstArcOAB{A0}{A3}{A2}\psline(A2)(A0)}}}%
[{\pstCircleOA*{A0}{A1}}] }%
\psline(A1)(A0)(A2)(A0)(A3)}%
\begin{document}
\[ \begin{psmatrix}[colsep=1.2cm, unit = 0.6]
%% nodes
\ThreeSectors[W] &\ThreeSectors[S] &\ThreeSectors[E] \\
\ThreeSectors[SW] &\ThreeSectors[WE] &\ThreeSectors[SE] \\
& \ThreeSectors
%%arrows \\
\psset{arrows=-, arrowinset=0.15, nodesep=-0.4pt, linewidth=0.6pt, npos = 0.3,labelsep = 8pt}
\ncline{1,1}{2,1}\ncput*{T₅} \ncline{1,1}{2,2}
\ncline{1,2}{2,1}\ncline{1,2}{2,3}
\nput[labelsep = 8pt]{-90}{1,2}{T₆}
\ncline{1,3}{2,2}\ncline{1,3}{2,3}\ncput*{T₇}
\ncline{2,1}{3,2}\ncline{2,2}{3,2}\ncput*{T₃}\ncline[nodesepB = -0.5pt]{2,3}{3,2}
\nput{-90}{2,1}{T₂} \nput{-90}{2,3}{T₄}
\nput{-90}{3,2}{T₁}
\end{psmatrix} \] %
\end{document}
答案4
还有一个 tikz 代码:
\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[1/.style={fill=lightgray},0/.style={fill=white}]
\foreach \a/\b/\c/\y/\x/\n in {1/1/1/0/1/1, 1/0/1/1/0/2, 0/1/1/1/1/3, 1/1/0/1/2/4, 0/0/1/2/0/5, 1/0/0/2/1/6, 0/1/0/2/2/7}{
\begin{scope}[shift={([scale=3]\x,\y)}]
\path coordinate (T\n) (0,-1.3) node[fill=white]{$T_\n$};
\foreach[count=\i] \s in {\a,\b,\c}{
\draw[rotate=90+\i*120,\s,thick] (0,0) -- (0:1) arc(0:120:1) -- cycle;
}
\end{scope}
}
\begin{pgfonlayer}{background}
\foreach \s/\t in {1/2,1/3,1/4,2/5,2/6,3/5,3/7,4/6,4/7}
\draw (T\s) -- (T\t);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}