如何通过连接到父节点的线数来连接线以表示密度(热度)。即,连接到同一父节点的线越多,汇聚线的热度就越高。这些线可以是 90 度角,可以是直线或曲线,但它们应该以某种方式汇聚。有没有一种合理的方式来表示这些数据?我们已经可以通过黑色连接线的密度看到图片上的热图效果,但是哪个节点有最多的传入连接应该更明显。
也许可以将线条做得稍微不透明一些,这样堆叠起来就能产生密度的视觉效果?或者可以涂上一些颜色?
\documentclass[12pt, a4paper]{report}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepackage{pgfplots}
\usepackage{xstring}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{tikz}
\usepackage{amsmath,caption}
\usepackage{svg}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric, arrows, positioning, arrows.meta, fit, backgrounds, patterns, arrows.meta,bending}
\newcommand\drawNodesSuperTight[2]{
\foreach \neurons [count=\lyrIdx] in #2 {
\StrCount{\neurons}{,}[\lyrLength]
\foreach \n [count=\nIdx] in \neurons {
\pgfmathsetmacro\xpos{(\nIdx-1)*\nodespacingSuperTight-\nodespacingSuperTight*(\lyrLength-1)/2}
\node[neuron2] (#1-\lyrIdx-\nIdx) at (\xpos, \layerdistanceSuperTight*\lyrIdx) {\n};
}
}
}
\newcommand\connectSomeNodesSmallArrow[2]{
\foreach \layer [count=\lyrIdx, evaluate=\lyrIdx as \nextLyr using int(\lyrIdx+1)] in #2
\foreach \neuron [count=\nIdx] in \layer
\foreach \edge in \neuron
\draw[my_arrow2] (#1-\lyrIdx-\nIdx.north) -- (#1-\nextLyr-\edge.south);
}
\newcommand{\nodeFontSuperTight}{\fontsize{4pt}{4pt}\selectfont}
\newcommand{\nodesizeSuperTight}{0.4cm}
\newcommand{\nodepaddingSuperTight}{0.01ex}
\newcommand{\nodespacingSuperTight}{0.1ex}
\newcommand{\layerdistanceSuperTight}{6ex}
\newcommand{\nodesize}{0.5cm}
\newcommand{\nodepadding}{0.2ex}
\newcommand{\nodespacing}{0.3ex}
\newcommand{\nodespacingThight}{0.15ex}
\newcommand{\layerdistance}{8ex}
\tikzset{
my_arrow/.style={-{Stealth[length=3pt]}, line width=0.1mm},
my_arrow2/.style={-{Stealth[length=1.5pt]}, line width=0.1mm},
neuron/.style={circle, draw, font=\tiny, minimum size=\nodesize, inner sep=\nodepadding, thick},
neuron2/.style={circle, draw, font=\nodeFontSuperTight, minimum size=\nodesizeSuperTight, inner sep=\nodepaddingSuperTight, thick},
legend/.style={font=\tiny, fill=white, inner sep=1pt},
odds/.style={legend,fill=white,pos=0.5,inner sep=2pt},
severity/.style={legend,right=1.4ex,align=left,anchor=west},
}
\begin{document}
\begin{tikzpicture}
\drawNodesSuperTight{fcnn}{{{129,549,233,137,586,175,624,176,112,594,242,114,212,21,117,439,184,26,122,28,124,94},{1,2,3,4,5,6},{1,2,4,5,6},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3},{HCS}}}
\connectSomeNodesSmallArrow{fcnn}{{{{1,2,5,6},5,{1,2,3,4,5},5,5,5,6,{1,2,5,6},{1,2,5,6},{1,2,5,6},5,{1,2,5},5,5,{1,5,6},{1,2,3,4,5,6},{5,6},5,5,5,{1,2,5,6},5},{{2,3,4,5},{2,3,5},{3,5},{2,3,5},{1,2,3,4,5},{1,2,3,4,5}},{{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{3,5,6,7,8,9,10,12,14},{1,2,3,4,5,6,7,8,9,10,11,12,13}},{{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3}},{1,1,1}}}
\end{tikzpicture}
\end{document}
答案1
我不知道这到底代表什么 - 它让我想起了神经网络 - 但是,假设受影响的是节点而不是(或不仅仅是线),我很想将堆叠效果应用于它们(或也应用于它们)。
您可以重写代码来执行此操作,但如果将堆叠仅应用于节点的边界而不是其内容,则可以通过简单的调整实现部分目标。
例如,
\documentclass[12pt,border=5pt]{standalone}
\usepackage{xstring}
\usepackage{tikz}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending,fit}
\newcommand\drawNodesSuperTight[2]{
\foreach \neurons [count=\lyrIdx] in #2 {
\StrCount{\neurons}{,}[\lyrLength]
\foreach \n [count=\nIdx] in \neurons {
\pgfmathsetmacro\xpos{(\nIdx-1)*\nodespacingSuperTight-\nodespacingSuperTight*(\lyrLength-1)/2}
\node[neuron2,draw=none,line width=0pt,minimum size=0pt] (#1-\lyrIdx-\nIdx) at (\xpos, \layerdistanceSuperTight*\lyrIdx) {\n};
}
}
}
\newcommand\connectSomeNodesSmallArrow[2]{
\foreach \layer [count=\lyrIdx, evaluate=\lyrIdx as \nextLyr using int(\lyrIdx+1)] in #2
\foreach \neuron [count=\nIdx] in \layer
\foreach \edge in \neuron
{
\node [fit=(#1-\lyrIdx-\nIdx),neuron2,inner sep=-0.8pt] (n-#1-\lyrIdx-\nIdx) {};
\node [neuron2,fit=(#1-\nextLyr-\edge),inner sep=-0.8pt] (n-#1-\nextLyr-\edge) {};
\draw[my_arrow2] (n-#1-\lyrIdx-\nIdx.north) -- (n-#1-\nextLyr-\edge.south);
}
}
\newcommand{\nodeFontSuperTight}{\fontsize{4pt}{4pt}\selectfont}
\newcommand{\nodesizeSuperTight}{0.4cm}
\newcommand{\nodepaddingSuperTight}{0.01ex}
\newcommand{\nodespacingSuperTight}{0.1ex}
\newcommand{\layerdistanceSuperTight}{6ex}
\newcommand{\nodesize}{0.5cm}
\newcommand{\nodepadding}{0.2ex}
\tikzset{
my_arrow2/.style={-{Stealth[length=1.5pt]}, line width=0.1mm},
neuron2/.style={circle, draw, font=\nodeFontSuperTight, minimum size=\nodesizeSuperTight, inner sep=\nodepaddingSuperTight, thick},
}
\begin{document}
\begin{tikzpicture}[draw opacity=.25,every node/.append style={draw opacity=.05}]
\drawNodesSuperTight{fcnn}{{{129,549,233,137,586,175,624,176,112,594,242,114,212,21,117,439,184,26,122,28,124,94},{1,2,3,4,5,6},{1,2,4,5,6},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3},{HCS}}}
\connectSomeNodesSmallArrow{fcnn}{{{{1,2,5,6},5,{1,2,3,4,5},5,5,5,6,{1,2,5,6},{1,2,5,6},{1,2,5,6},5,{1,2,5},5,5,{1,5,6},{1,2,3,4,5,6},{5,6},5,5,5,{1,2,5,6},5},{{2,3,4,5},{2,3,5},{3,5},{2,3,5},{1,2,3,4,5},{1,2,3,4,5}},{{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{3,5,6,7,8,9,10,12,14},{1,2,3,4,5,6,7,8,9,10,11,12,13}},{{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3}},{1,1,1}}}
\end{tikzpicture}
\end{document}
如果不知道要表示什么,就不可能确定什么看起来正确,但您可能希望边缘和节点边界具有不同的值。否则,您会在其中一个方面获得不足的变化。
请注意,这张糟糕的图像是最新、最出色的 KDE 升级版的产物,它以过时的方式让原本功能完好的桌面在最初完全无法使用。修复图形副本目前并不是我的首要任务,所以你只能相信我的话,原始图像与此完全不同。
答案2
也许你可以使用@cfr 的想法并添加颜色。(我也尝试过混合模式,但没有成功)。颜色很糟糕,但你明白我的意思......
注意箭头很奇怪;你应该将每条绘制的线条括在一个透明度组中(参见代码中注释掉的部分),但是如果我使用它们,生成的 PDF 会杀死我的查看器(okular
,evince
如果放大的话也会),因为它无法呈现图像。
\documentclass[12pt, a4paper]{report}
\usepackage{xstring}
\usepackage{tikz}
\usepackage{svg}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric, arrows, positioning, arrows.meta, fit, backgrounds, patterns, arrows.meta,bending}
\newcommand\drawNodesSuperTight[2]{
\foreach \neurons [count=\lyrIdx] in #2 {
\StrCount{\neurons}{,}[\lyrLength]
\foreach \n [count=\nIdx] in \neurons {
\pgfmathsetmacro\xpos{(\nIdx-1)*\nodespacingSuperTight-\nodespacingSuperTight*(\lyrLength-1)/2}
\node[neuron2] (#1-\lyrIdx-\nIdx) at (\xpos, \layerdistanceSuperTight*\lyrIdx) {\n};
}
}
}
\newcommand\connectSomeNodesSmallArrow[3][]{
\foreach \layer [count=\lyrIdx, evaluate=\lyrIdx as \nextLyr using int(\lyrIdx+1)] in #3
\foreach \neuron [count=\nIdx] in \layer
\foreach \edge in \neuron {
% this transparency group kills my viewer(s)
%\begin{scope}[transparency group, opacity=0.3]
\draw[my_arrow2, line cap=round, #1] (#2-\lyrIdx-\nIdx.north) -- (#2-\nextLyr-\edge.south);
% \end{scope}
}
}
\newcommand{\nodeFontSuperTight}{\fontsize{4pt}{4pt}\selectfont}
\newcommand{\nodesizeSuperTight}{0.4cm}
\newcommand{\nodepaddingSuperTight}{0.01ex}
\newcommand{\nodespacingSuperTight}{0.1ex}
\newcommand{\layerdistanceSuperTight}{6ex}
\newcommand{\nodesize}{0.5cm}
\newcommand{\nodepadding}{0.2ex}
\newcommand{\nodespacing}{0.3ex}
\newcommand{\nodespacingThight}{0.15ex}
\newcommand{\layerdistance}{8ex}
\tikzset{
my_arrow/.style={-{Stealth[length=3pt]}, line width=0.1mm},
my_arrow2/.style={-{Stealth[length=3.5pt]}, line width=0.4mm},
neuron/.style={circle, draw, font=\tiny, minimum size=\nodesize, inner sep=\nodepadding, thick},
neuron2/.style={circle, draw, font=\nodeFontSuperTight, minimum size=\nodesizeSuperTight, inner sep=\nodepaddingSuperTight, thick},
legend/.style={font=\tiny, fill=white, inner sep=1pt},
odds/.style={legend,fill=white,pos=0.5,inner sep=2pt},
severity/.style={legend,right=1.4ex,align=left,anchor=west},
}
\newcommand{\DoNodes}{%
\drawNodesSuperTight{fcnn}{{{129,549,233,137,586,175,624,176,112,594,242,114,212,21,117,439,184,26,122,28,124,94},{1,2,3,4,5,6},{1,2,4,5,6},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3},{HCS}}}
}
\newcommand{\DoConns}[1]{%
\connectSomeNodesSmallArrow[#1]{fcnn}{{{{1,2,5,6},5,{1,2,3,4,5},5,5,5,6,{1,2,5,6},{1,2,5,6},{1,2,5,6},5,{1,2,5},5,5,{1,5,6},{1,2,3,4,5,6},{5,6},5,5,5,{1,2,5,6},5},{{2,3,4,5},{2,3,5},{3,5},{2,3,5},{1,2,3,4,5},{1,2,3,4,5}},{{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{1,2,3,4,5,6,7,8,9,10,11,12,13,14},{3,5,6,7,8,9,10,12,14},{1,2,3,4,5,6,7,8,9,10,11,12,13}},{{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3}},{1,1,1}}}
}
\begin{document}
\begin{tikzpicture}
\DoNodes
\DoConns{draw opacity=.25, line width=2pt, color=green}
\DoConns{draw opacity=.25, line width=2pt, color=red}
\end{tikzpicture}
\end{document}