我有以下帶有 Latexsmartdiagram
包的程式碼,可以產生附加的氣泡圖。
但我希望能夠擁有子衛星在其中(見下面的原型圖)。
- 可以這樣做嗎
smartdiagram
?如果沒有,我如何直接使用tikz
or 或類似的方法複製它?
謝謝!
\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}