我制作了一个气泡图,中心气泡周围有 4 个气泡。但它们呈“十字”状,4 个气泡分别位于北、南、东和西的位置。我想旋转周围的气泡,使它们看起来更像“X”,或者位于东北、东南、西北和西南的位置。有什么建议吗?
答案1
这本身不受支持,但找到解决方法也不难。
\documentclass[border=2mm]{standalone}
\usepackage{smartdiagram}
\makeatletter
\NewDocumentCommand{\smartdiagramx}{r[] m}{%
\StrCut{#1}{:}\diagramtype\option
\IfStrEq{\diagramtype}{bubble diagram}{% true-bubble diagram
\begin{tikzpicture}[every node/.style={align=center,let hypenation}]
\foreach \smitem [count=\xi] in {#2}{%
\global\let\maxsmitem\xi%
}%
\pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
\foreach \smitem [count=\xi] in {#2}{%
\ifnumequal{\xi}{1}{%true
\node[bubble center node](center bubble){\smitem};
}{%false
\pgfmathtruncatemacro{\xj}{\xi-1}
\pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj+\option}
\edef\col{\@nameuse{color@\xj}}
\node[bubble node] (module\xi) at (center bubble.\angle) {\smitem };
}%
}%
\end{tikzpicture}
}{}%end if
}% end command
\makeatother
\begin{document}
\smartdiagramx[bubble diagram:45]{Build a program,Set up,Run,Analyze,Modify~/\\ Add}
\end{document}
结果:
使用option
图表类型后的部分(例如bubble diagram:45
)来包含相对于原始位置的偏移角度。
根据编辑中的要求,这个技巧也适用于演示模式:
\documentclass{beamer}
\usepackage{smartdiagram}
\makeatletter
\NewDocumentCommand{\smartdiagramanimatedx}{r[] m}{%
\StrCut{#1}{:}\diagramtype\option
\IfStrEq{\diagramtype}{bubble diagram}{% true-bubble diagram
\begin{tikzpicture}[every node/.style={align=center,let hypenation}]
\foreach \smitem [count=\xi] in {#2}{%
\global\let\maxsmitem\xi%
}%
\pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
\foreach \smitem [count=\xi] in {#2}{%
\ifnumequal{\xi}{1}{%true
\node[bubble center node, smvisible on=<\xi->](center bubble){\smitem};
}{%false
\pgfmathtruncatemacro{\xj}{\xi-1}
\pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj+\option}
\edef\col{\@nameuse{color@\xj}}
\node[bubble node, smvisible on=<\xi->] (module\xi) at (center bubble.\angle) {\smitem };
}%
}%
\end{tikzpicture}
}{}%end if
}% end command
\makeatother
\begin{document}
\begin{frame}{example}
\smartdiagramanimatedx[bubble diagram:45]{Build a program,Set up,Run,Analyze,Modify~/\\ Add}
\end{frame}
\end{document}
结果:
答案2
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[mindmap, concept color=red!40]
\node [concept] {Bubble}
child[grow=45] {node[concept] {Bubble 1}}
child[grow=135] {node[concept] {Bubble 2}}
child[grow=225] {node[concept] {Bubble 3}}
child[grow=-45] {node[concept] {Bubble 4}};
\end{tikzpicture}
\end{document}