我得到了带有 Latex 包的以下代码smartdiagram
,可以生成附加的气泡图。
但我希望能够拥有子卫星其中(见下面的原型图像)。
- 可以使用 来实现吗
smartdiagram
?如果不行,我该如何使用tikz
或 或类似方法直接复制此操作?
谢谢!
\documentclass[a4paper]{article}
\usepackage{smartdiagram}
\begin{document}
\smartdiagramset{
bubble center node font = \footnotesize,
bubble node font = \footnotesize,
% specifies the minimum size of the bubble center node
bubble center node size = 0.1cm,
% specifies the minimum size of the bubbles
bubble node size = 0.9cm,
% specifies which is the distance among the bubble center node and the other bubbles
distance center/other bubbles = 0.5cm,
% sets the distance from the text to the border of the bubble center node
%distance text center bubble = 0.5cm,
}
\smartdiagram[bubble diagram]{
\normalsize{Interest} \\ \normalsize{Areas},
\textbf{DLTs/} \\ \textbf{Blockchain,} \\ \textbf{Web3},
\textbf{Big/Fast Data} \\ \textbf{\& Streaming},
\textbf{Artificial} \\ \textbf{Intelligence},
\textbf{Functional} \\ \textbf{Programming}
}
\end{document}
我拥有的与我想要的
我尝试过
我尝试用一张新图替换卫星Functional Programming
,目的是让卫星成为一颗新行星,这样就可以拥有更多的卫星(子代)。但结果却一团糟。我的意思是:
\textbf{Functional} \\ \textbf{Programming}
到
\smartdiagram[bubble diagram]{ ... }
答案1
重制 OP 答案,这次没有使用 Chat-GPT 的帮助。生成的代码更短更清晰:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,
calc,
positioning,}
\begin{document}
\begin{tikzpicture}[
base/.style = {circle, draw=white, line width=1.5pt, draw opacity=1,
minimum size=#1, align=center, font=\bfseries},
planet/.style = {base=32mm, fill=orange},
satellite/.style = {base=13mm, fill=#1, fill opacity=0.7},
satchild/.style = {base=12mm, fill=green!40, fill opacity=0.7},
]
% Planet
\node (P) [planet] {Interest \\ Areas};
% Satellits
\node [satellite=blue!30, right=-7mm of P] {DLTs/\\ Blockchain,\\ Web3};
\node [satellite=gray!30, above=-7mm of P] {Big/Fast Data\\ \& Streaming};
\node [satellite=yellow!30,left=-7mm of P] {Artificial\\ Intelligence};
\node (fp) [satellite=green,below=-7mm of P] {Functional\\ Programming};
% Satellits children
\node [satchild, below left=-4mm and 0mm of fp] {Unison};
\node [satchild, below right=-4mm and 0mm of fp] {ZIO,\\ Kyo};
\node [satchild, below=-4mm of fp] {Effect,\\ systems};
\end{tikzpicture}
\end{document}
从问题来看,不清楚图像是否应该有自己的黑色背景。如果是,您可以在前面添加\end{tikzpicture}
以下代码行:
% Background, if you like to have it in black
\scoped[on background layer]
\draw[line width=6mm, fill] (current bounding box.south west) rectangle (current bounding box.north east);
答案2
我最终在 Chat-GPT 的帮助下使用 TikZ 成功实现了这一点。以下是结果和代码,供参考:
\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{shapes,positioning,calc}
\begin{document}
\begin{tikzpicture}
% Define styles for the nodes
\tikzstyle{planet}=[circle, fill=orange, minimum size=3.2cm, align=center]
\tikzstyle{satellite}=[circle, draw, fill=green!40, minimum size=1.3cm, align=center, opacity=0.7, font=\footnotesize, postaction={draw=white, line width=1.5pt, opacity=1}]
\tikzstyle{satchild}=[circle, draw, fill=green!25, minimum size=0.7cm, align=center, opacity=0.7, font=\footnotesize, postaction={draw=white, line width=1pt, opacity=1}]
% Draw the central planet
\node (interests) [planet] {Interest \\ Areas};
\node (bigdata) [satellite, above=-0.7cm of interests, fill=gray!30] {\textbf{Big/Fast Data} \\ \textbf{\& Streaming}};
\node (blockchain) [satellite, right=-0.7cm of interests, fill=blue!30] {\textbf{DLTs/} \\ \textbf{Blockchain,} \\ \textbf{Web3}};
\node (fp) [satellite, below=-0.7cm of interests] {\textbf{Functional} \\ \textbf{Programming}};
\node (ai) [satellite, left=-0.7cm of interests, fill=yellow!30] {\textbf{Artificial} \\ \textbf{Intelligence}};
% Sat. children
\node (unison) [satchild] at ($(fp) + (205:1.4cm)$) {Unison};
\node (unison) [satchild] at ($(fp) + (-25:1.4cm)$) {ZIO, Kyo};
\node (unison) [satchild, below=-4mm of fp] {Effect,\\ systems};
\end{tikzpicture}
\end{document}
答案3
code-noise
为了展示此 ChatGPT 方法生成和留下的数量,下面是一些重构OP 发布的代码作为解决方案。
如您所见,剩下的内容揭示了some residual nastiness
所选方法的不足。例如,我想进一步重构,例如为了提高可读性,但节点语句不知何故既有优点也有缺点。即,如果不付出更多努力,很难将这些语句变成一组易于理解、格式整齐的单行代码。
我还想知道,left-to-right orientation
原始草图发生了什么,它变成了从下到上的方向。重构后,现在可能比发布的 GPT 代码更容易更改。
我没有深入研究它,但想知道为什么postaction
SAT 和 CSAT 风格中真的需要它。
As a rule of thumb
:
- 如果代码看起来丑陋,则可能是错误的或难以更改
- 如果代码排列整齐,可能更正确,应该可以编译
- 所以所有这些都是预防错误的步骤,鼓励随着事态的发展而做出改变。
顺便说一句,code-noise
例如,可读性差,当你向后工作时就会少一些:
- 首先发布节点等
- 引入各种风格
- 我现在发布的代码更好一些,但从这个角度来看仍然不够好。
\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{positioning}
% ~~~ REFACTORING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% --- removed unused node name ---
% --- removed bold font: not needed ----------
% --- replaced style-names for better read-ability & error prevention ----
% --- moved node names after the style statement (my convention) ---
% --- renamed node names: capitalized, shorter -----
% --- removed calc, replaced shift statements --------------
% --- removed shapes: obviously NOT needed ----------
% --- replaced 0.7cm by 7mm - grasp it at 1 glance w.o. thinking ---
% --- refactoring common styles CMN + removed not needed ones ---------
% --- same for opacity --------
% --- some, still insufficient, reformatting of code ---
\begin{document}
\begin{tikzpicture}
% Define styles for the nodes
\tikzstyle{CMN} = [circle, align=center]
\tikzstyle{OPC} = [opacity=0.7]
\tikzstyle{PAOPC} = [draw=white,opacity=1]
\tikzstyle{PLANET}= [CMN, fill=orange, minimum size=3.2cm]
\tikzstyle{SAT} = [CMN, OPC, fill=green!40, minimum size=1.3cm,
font=\footnotesize,
postaction={PAOPC, line width=1.5pt}]
\tikzstyle{CSAT} = [CMN, OPC, fill=green!25, minimum size=0.7cm,
font=\footnotesize,
postaction={PAOPC, line width=1pt}]
% Draw the central planet
\node [PLANET] (IA) {Interest\\Areas};
\node [SAT, above=-7mm of IA,
fill=gray!30] {Big/Fast Data\\\& Streaming};
\node [SAT, right=-7mm of IA,
fill=blue!30] {DLTs/\\Blockchain,\\Web3};
\node [SAT, below=-7mm of IA] (FP) {Functional\\Programming};
\node [SAT, left=-7mm of IA,
fill=yellow!30] {Artificial\\Intelligence};
% Sat. children
\node [CSAT] at ([shift=(205:1.4cm)] FP) {Unison};
\node [CSAT] at ([shift=(-25:1.4cm)] FP) {ZIO, Kyo};
\node [CSAT,
below=-4mm of FP] {Effect,\\systems};
\end{tikzpicture}
\end{document}