答案1
我不认为存在这种图表的库,而且我认为,考虑到上图中单个元素位置的多样性和唯一性,最简单的方法可能是仅使用预定义的形状(例如和rectangle
(diamond
后者可通过库获得shapes.geometric
))并手动添加其他内容。
但是,您当然可以创建自己的形状或使用样式增强现有形状,或者可以\pic
像以下示例一样使用 s ,这可能有助于您绘制上图(但您应该熟悉\pic
s 的一般工作原理):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows.meta}
\tikzset{
% enhanced rectangle
enhanced rectangle/base/.style={
draw,
rectangle,
align=center,
minimum width=7em,
minimum height=2.5em,
inner sep=5pt,
},
enhanced rectangle/text/.initial={},
pics/enhanced rectangle/.style={
code={
\tikzset{#1}
\node[enhanced rectangle/base] (-base) at (0,0) {
\pgfkeysvalueof{/tikz/enhanced rectangle/text}
};
\tikzset{enhanced node additions/construction}
}
},
% enhanced diamond
enhanced diamond/base/.style={
draw,
diamond,
align=center,
minimum width=7.5em,
minimum height=2em,
inner sep=1pt,
},
enhanced diamond/text/.initial={},
pics/enhanced diamond/.style={
code={
\tikzset{#1}
\node[enhanced diamond/base] (-base) at (0,0) {
\pgfkeysvalueof{/tikz/enhanced diamond/text}
};
\tikzset{enhanced node additions/construction}
}
},
% enhanced node additions
enhanced node additions/.initial={},
enhanced node additions/node/.style={draw, circle, inner sep=2pt},
enhanced node additions/label/.style={},
enhanced node additions/radius/.initial={2.25cm and 1.25cm},
enhanced node additions/connected/.code={
\tikzset{
enhanced node additions/connected/path/.style={draw},
enhanced node additions/connected/node/.style={enhanced node additions/node, fill},
}
},
enhanced node additions/connected/path/.style={},
enhanced node additions/connected/node/.style={},
enhanced node additions/connected/start angle/.initial={0},
enhanced node additions/connected/end angle/.initial={0},
enhanced node additions/connected/radius/.initial={1.75cm and 0.75cm},
enhanced node additions/construction/.code={
\pgfkeysgetvalue{/tikz/enhanced node additions}{\enhanceddiamondadditionslist}
\ifx\enhanceddiamondadditionslist\empty\else
\foreach \a/\s/\l [count=\i] in \enhanceddiamondadditionslist {
\tikzset{
enhanced node additions/node \i/.style={},
enhanced node additions/label \i/.style={},
}
\node[enhanced node additions/node, enhanced node additions/node \i, label={[enhanced node additions/label, enhanced node additions/label \i]\a:\l}, \s] (-addition node \i) at (\a:\pgfkeysvalueof{/tikz/enhanced node additions/radius}) {};
\draw (-base) -- (-addition node \i) coordinate[midway] (-addition edge \i);
}
\draw (\pgfkeysvalueof{/tikz/enhanced node additions/connected/start angle}:\pgfkeysvalueof{/tikz/enhanced node additions/connected/radius})
arc (\pgfkeysvalueof{/tikz/enhanced node additions/connected/start angle}:\pgfkeysvalueof{/tikz/enhanced node additions/connected/end angle}:\pgfkeysvalueof{/tikz/enhanced node additions/connected/radius})
node[enhanced node additions/connected/node] (-addition connect node) {};
\fi
},
}
\begin{document}
\begin{tikzpicture}
\pic (rectangle 1) at (0,0) {enhanced rectangle={
enhanced rectangle/text={Edizione corso},
enhanced node additions={
215//Num. part.,
280//Data inizio,
325//Data fine
},
enhanced node additions/connected,
enhanced node additions/connected/start angle=250,
enhanced node additions/connected/end angle=290,
}};
\draw (rectangle 1-base.250) -- ++(0,-2);
\pic (diamond 1) at (5,0) {enhanced diamond={
enhanced diamond/text={Foo},
enhanced node additions={
135/fill/Ciao,
45/fill/Hello,
0//Bye
},
enhanced node additions/connected,
enhanced node additions/connected/start angle=-20,
enhanced node additions/connected/end angle=65,
}};
\node[above] at (diamond 1-addition edge 1) {(1,0)};
\draw (rectangle 1-base) -- (diamond 1-base) node[above, pos=0.25] {(1,N)};
\draw[<-, double, double distance=2pt, >={Triangle[length=5pt]}] (diamond 1-base) -- ++(0,-2);
\end{tikzpicture}
\end{document}