我尝试绘制此图
rpapa 向我展示了如何开始通过发布代码来绘制 3 个大框,顶部有圆圈,左侧有标签,中间有箭头。这很有帮助。
我设法修改了该代码,以便为某些元素着色。我还创建了一个新命令,开始绘制底部的大框,并在此框中的圆圈与上方框中的圆圈之间建立一些连接。但是,我不知道如何绘制从丘脑框到杏仁核中的圆圈的连接,因为该箭头需要从大框的边界出发,而不是从其中的某个圆圈出发。
我怎样才能从大盒子的边缘而不是从其中一个圆圈绘制连接?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,fit}
\begin{figure*}[!ht]
\centering
\newcommand{\bloc}[2]{
\begin{scope}[shift={#1}]
\begin{scope}[every node/.style={circle, draw, minimum size=2em}]
\node[circle, draw] [blue](#2-c1){};
\node[below left=1em of #2-c1][blue](#2-c2){};%to draw a circle inside a box
\node[below left=1em of #2-c2][blue](#2-c3){};
\node[below left=1em of #2-c3][blue](#2-c4){};
\end{scope}
\node[above left=1em and 0em of #2-c1][blue](#2-tt){#2};%to label the box by names Thalamus,Sensory Cortex
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-tt)][red](#2){};%to draw a boxes
\end{scope}
}
\newcommand{\blocwithSum}[2]{
\begin{scope}[shift={#1}]
\begin{scope}[every node/.style={circle, draw, minimum size=2em}]
\node[circle, draw] [red](#2-c1){};
\node[below left=1em of #2-c1][red](#2-c2){};
\node[below left=1em of #2-c2][red](#2-c3){};
\node[below left=1em of #2-c3][red](#2-c4){};
\node[below right=2em and 1em of #2-c1][blue](#2-sum){\large $\Sigma$};
\end{scope}
\node[above left=1em and 0em of #2-c1][red](#2-tt){#2};%to label a box by name Orbitofrontal
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-tt) (#2-sum)][blue](#2){};%to draw a box
\draw[->,red,thick] (#2-c1)-|(#2-sum);%to draw connection lines to sum
\draw[->,red,thick] (#2-c2)--++(2em,0) --(#2-sum);
\draw[->,red,thick] (#2-c3)--++(2em,0) --(#2-sum);
\draw[->,red,thick] (#2-c4)-|(#2-sum);
\end{scope}
}
\newcommand{\blocwithz}[2]{
\begin{scope}[shift={#1}]
\begin{scope}[every node/.style={circle, draw, minimum size=2em}]
\node[circle, draw][cyan] (#2-c1){};
\node[below left=1em of #2-c1][cyan](#2-c2){};%to draw circles
\node[below left=1em of #2-c2][cyan](#2-c3){};
\node[below left=1em of #2-c3][cyan](#2-c4){};
\node[below left=1 em of #2-c4](#2-c5){};
\node[below right=2em and 1em of #2-c1][red](#2-sum){\large $\Sigma$};%to draw Sum
% \node[below right=2em and 0 em of#2-sum](#2-sums){\large$\Sigma$};
\end{scope}
\node[above left=1em and 0em of #2-c1][cyan](#2-tt){#2}; %to label the box name Amagydala
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-c5) (#2-tt) (#2-sum)][cyan](#2){}; %to draw the box
\draw[->,cyan,thick] (#2-c1)-|(#2-sum);%to draw connection lines to Sum
\draw[->,cyan,thick] (#2-c2)--++(2em,0) --(#2-sum);
\draw[->,cyan,thick] (#2-c3)--++(2em,0) --(#2-sum);
\draw[->,cyan,thick] (#2-c4)-|(#2-sum);
\end{scope}
}
\begin{tikzpicture}
\bloc{(0,0)}{Thalamus} %the position of box 1
\bloc{(4cm,0)}{Sensory Cortex} %the position of box 2
\blocwithSum{(9cm,0)}{Orbitofrontal Cortex} %the position of box 3
\blocwithz{(4cm,-7cm)}{Amygdala} % the position of box 4
\foreach \ii in{1,2,3,4} {
\node[draw][red](E\ii) at (Thalamus-c\ii-|-5,0){$S_{\ii}$};%to draw the inputs stimulus and their position
\draw[->,thick][blue] (E\ii)-- (Thalamus-c\ii);
\draw[->,thick] [red](Thalamus-c\ii) -- (Sensory Cortex-c\ii);
\draw[->,thick] [blue] (Sensory Cortex-c\ii) -- (Orbitofrontal Cortex-c\ii);
\draw[->,thick] [red] (Sensory Cortex-c\ii) -- (Amygdala-c\ii);
%\draw[->,thick] [red] (g) -- (Amygdala-c\ii);
}
\end{tikzpicture}
\caption{ Routes of limbic system}
\label{FB2}
\end{figure*}
\end{document}
以下是我所得到的rpapa 的回答:
答案1
可能但不完美的解决方案
\documentclass[border=10pt]{standalone}
\usepackage{tikz,bm}
\usetikzlibrary{calc,positioning,fit,arrows}
\begin{document}
\begin{tikzpicture}
[%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
node distance=.2cm,
whiteCircle/.style={circle,draw,very thick,
inner sep=0pt,minimum size=6mm},
greyCircle/.style={circle,draw,fill=gray,very thick,
inner sep=0pt,minimum size=2mm},
greyRectangle/.style={rectangle,draw,fill=gray, very thick,
inner sep=0pt,minimum width=2mm, minimum height=7mm},
solidLine/.style={->,very thick,>=latex},
dashLine/.style={->,dashed,very thick,>=latex},
rect/.style={rectangle,draw,inner sep=0.0pt,minimum height=2mm}
]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node [whiteCircle] (A1) {A1};
\node [whiteCircle] (B1) [below left=of A1] {B1};
\node [whiteCircle] (C1) [below left=of B1] {C1};
\node [whiteCircle] (D1) [below left=of C1] {D1};
\node [draw, thick, inner sep=0.4cm, fit={(A1) (B1) (C1) (D1)}] (ThalamusBox) {};
\node[below left, xshift=3mm] at (ThalamusBox.north) {\textbf{Thalamus}};
%##########################################################
\node[rect,node distance=5cm] (K1) [left=of A1] {$\bm{K_{p_{t-4}}}$};
\node[rect] (K2) [below=of K1] {$\bm{K_{p_{t-3}}}$};
\node[rect] (K3) [below=of K2] {$\bm{K_{p_{t-2}}}$};
\node[rect] (K4) [below=of K3] {$\bm{K_{p_{t-1}}}$};
%##########################################################
\node [whiteCircle, node distance=3cm] (A2) [right=of A1] {A2};
\node [whiteCircle] (B2) [below left=of A2] {B2};
\node [whiteCircle] (C2) [below left=of B2] {C2};
\node [whiteCircle] (D2) [below left=of C2] {D2};
\node [draw, thick, inner sep=0.4cm, fit={(A2) (B2) (C2) (D2)}] (SensoryBox) {};
\node[below, xshift=-2mm] at (SensoryBox.north) {\textbf{Sensory Cortex}};
%##########################################################
\node [whiteCircle, node distance=6.5cm] (A3) [right=of A2] {A3};
\node [whiteCircle] (B3) [below left=of A3] {B3};
\node [whiteCircle] (C3) [below left=of B3] {C3};
\node [whiteCircle] (D3) [below left=of C3] {D3};
\node [whiteCircle,node distance=1.9cm] (S3) [right of= C3] {$\bm{\sum}$};
\node [draw, thick, inner sep=0.4cm, fit={(A3) (B3) (C3) (D3) (S3)}] (OrbitoBox) {};
\node[below, xshift=0mm] at (OrbitoBox.north) {\textbf{Orbitofrontal Cortex}};
%##########################################################
\node [greyCircle, node distance=3cm] (a4) [below=of S3] {a4};
\node [greyRectangle,node distance=2.0cm] (b4) [left=of a4] {b4};
\node [greyCircle,node distance=3.2cm] (c4) [left=of b4] {c4};
\node [whiteCircle,node distance=1.9cm] (S41) [below of= a4] {$\bm{\sum}$};
\node [greyCircle,node distance=0.9cm] (d4) [left=of S41] {d4};
\node [rect,node distance=1cm,inner sep=1.0pt,] (Kp) [right=of S41] {$\bm{\hat{K}_{p_{t}}}$};
\node[greyRectangle] (e4) at (c4 |- d4) {e4};
\node[rect] (K5) at (K4 |- c4) {$\bm{K_{p_{t}}}$};
\node[whiteCircle,node distance=1.7cm] (A4) [below=of e4] at (barycentric cs:d4=0.1,e4=0.1) {A4};
\node [whiteCircle] (B4) [below left=of A4] {B4};
\node [whiteCircle] (C4) [below left=of B4] {C4};
\node [whiteCircle] (D4) [below left=of C4] {D4};
\node [whiteCircle] (E4) [below left=of D4] {E4};
\node [greyCircle,node distance=3.6cm] (f4) [below=of d4] {f4};
\node [whiteCircle,node distance=1.5cm] (S42) [left of= f4] {$\bm{\sum}$};
\node [whiteCircle,node distance=1.cm] (S43) [above of= S42] {$\bm{\sum}$};
\node [draw, thick, inner sep=0.4cm, fit={(a4)(b4)(c4)(d4)(E4)(S41)}] (AmyBox) {};
\node[above, xshift=2.8cm] at (AmyBox.south) {\textbf{Amygdata}};
\draw[solidLine] (A1) -- (A2);
\draw[solidLine] (B1) -- (B2);
\draw[solidLine] (C1) -- (C2);
\draw[solidLine] (D1) -- (D2);
\draw[solidLine] (A2) -- node (w4) [above, midway,xshift=-6mm] {$\textbf{w}_{4}$} (A3);
\draw[solidLine] (B2) -- (B3);
\draw[solidLine] (C2) -- (C3);
\draw[solidLine] (D2) -- (D3);
\node[node distance=.15cm] (w3) [below=of w4] {$\textbf{w}_{3}$};
\node[node distance=.15cm] (w2) [below=of w3] {$\textbf{w}_{2}$};
\node[node distance=.15cm] (w1) [below=of w2] {$\textbf{w}_{1}$};
\draw[solidLine] (A3.east) -| (S3);
\draw[solidLine] (B3.east) --++(1em,0) --(S3);
\draw[solidLine] (C3.east) --(S3);
\draw[solidLine] (D3.east) --++(4em,0) --(S3);
\draw[solidLine] (S3) -- node[anchor=north west,yshift=-4mm] {$\bm{E_{o}}$} (a4);
\draw[solidLine] (a4) -- node[anchor=north east,yshift=-3mm] {\textbf{-}}(S41);
\draw[dashLine] (a4) -- (b4);
\draw[dashLine] (c4) -- (b4);
\draw[dashLine] (b4) -- (w4.north east);
\draw[dashLine] (c4) -- (e4);
\draw[dashLine] (d4) -- (e4);
\draw[solidLine] (d4) -- (S41);
\draw[solidLine] (A2) |- node[midway,above,xshift=3mm] (v4) {$\textbf{v}_{4}$} (A4);
\draw[solidLine] (B2) |- node[midway,above,xshift=3mm] (v3) {$\textbf{v}_{3}$}(B4);
\draw[solidLine] (C2) |- node[midway,above,xshift=3mm] (v2) {$\textbf{v}_{2}$}(C4);
\draw[solidLine] (D2) |- node[midway,above,xshift=3mm] (v1) {$\textbf{v}_{1}$} (D4);
\draw[solidLine] (ThalamusBox) |- node[midway,above,xshift=25mm] (v1) {$\textbf{v}_{\psi}$} (E4);
\draw[solidLine] (A4) -| (S43);
\draw[solidLine] (S43) -- (S42);
\draw[solidLine] (S43.east) -| node[anchor=south west,yshift=2mm] {$\bm{E'_{a}}$} (b4);
\draw[solidLine] (B4.east) --++(1em,0) --(S43);
\draw[solidLine] (C4.east) --++(9mm,0) --(S43);
\draw[solidLine] (D4.east) --++(15mm,0) --(S43);
\draw[solidLine] (E4.east) --++(21mm,0) --(S42.south west);
\draw[solidLine,-] (f4) -- node[midway,above] {$\bm{E_{a}}$} (S42);
\draw[solidLine] (S41) -- (Kp);
\draw[solidLine] (K1) -- (A1);
\draw[solidLine] (K2) -- (B1);
\draw[solidLine] (K3) -- (C1);
\draw[solidLine] (K4) -- (D1);
\draw[dashLine] (K5) -- (c4);
\end{tikzpicture}
\end{document}
我保留了节点的名称,以便您可以轻松修改代码。完成代码后,请将其删除。
答案2
绘制丘脑框的外部大节点的名称就是Thalamus
:
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-tt), red](#2){};
绘制大节点的框。节点的名称是(#2)
绘制时提供的第二个参数:
\bloc{(0,0)}{Thalamus} %the position of box 1
Thalamus
在这种情况下您需要连接的名称也是如此:
\draw [->, thick] (Thalamus) |- (Amygdala-c5);
平均值|-
是垂直走向,而不是对角线走向,即不是直线走向。
完整代码:
\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{calc,positioning,fit}
\begin{document}
% rpapa's code is the basis for this: http://tex.stackexchange.com/a/279011/
\newcommand{\bloc}[2]{%
\begin{scope}[shift={#1}]
\begin{scope}[every node/.style={circle, draw, minimum size=2em, blue}]
\node[circle, draw] (#2-c1){};
\node[below left=1em of #2-c1](#2-c2){};
\node[below left=1em of #2-c2](#2-c3){};
\node[below left=1em of #2-c3](#2-c4){};
\end{scope}
\node[above left=1em and 0em of #2-c1, blue](#2-tt){#2};
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-tt), red](#2){};
\end{scope}}
\newcommand{\blocwithSum}[2]{%
\begin{scope}[shift={#1}]
\begin{scope}[every node/.style={circle, draw, minimum size=2em, red}]
\node[circle, draw] (#2-c1){};
\node[below left=1em of #2-c1](#2-c2){};
\node[below left=1em of #2-c2](#2-c3){};
\node[below left=1em of #2-c3](#2-c4){};
\node[below right=2em and 1em of #2-c1, blue](#2-sum){\large $\Sigma$};
\end{scope}
\node[above left=1em and 0em of #2-c1, red](#2-tt){#2};
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-tt) (#2-sum), blue](#2){};
\begin{scope}[draw=red, thick, ->]
\draw (#2-c1)-|(#2-sum);
\draw (#2-c2)--++(2em,0) --(#2-sum);
\draw (#2-c3)--++(2em,0) --(#2-sum);
\draw (#2-c4)-|(#2-sum);
\end{scope}
\end{scope}}
\newcommand{\blocwithz}[2]{%
\begin{scope}[shift={#1}]
\begin{scope}[every node/.style={circle, draw, minimum size=2em, cyan}]
\node[circle, draw] (#2-c1){};
\node[below left=1em of #2-c1](#2-c2){};%to draw circles
\node[below left=1em of #2-c2](#2-c3){};
\node[below left=1em of #2-c3](#2-c4){};
\node[below left=1 em of #2-c4](#2-c5){};
\node[below right=2em and 1em of #2-c1][red](#2-sum){\large $\Sigma$};%to draw Sum
% \node[below right=2em and 0 em of#2-sum](#2-sums){\large$\Sigma$};
\end{scope}
\node[above left=1em and 0em of #2-c1, cyan][cyan](#2-tt){#2}; %to label the box name Amagydala
\node[draw,fit=(#2-c1) (#2-c2) (#2-c3) (#2-c4) (#2-c5) (#2-tt) (#2-sum), cyan](#2){}; %to draw the box
\begin{scope}[draw=cyan, thick, ->]
\draw (#2-c1)-|(#2-sum);
\draw (#2-c2)--++(2em,0) --(#2-sum);
\draw (#2-c3)--++(2em,0) --(#2-sum);
\draw (#2-c4)-|(#2-sum);
\end{scope}
\end{scope}%
}
\begin{tikzpicture}
\bloc{(0,0)}{Thalamus} %the position of box 1
\bloc{(4cm,0)}{Sensory Cortex} %the position of box 2
\blocwithSum{(9cm,0)}{Orbitofrontal Cortex} %the position of box 3
\blocwithz{(4cm,-7cm)}{Amygdala} % the position of box 4
\foreach \ii in{1,2,3,4} {
\node[draw][red](E\ii) at (Thalamus-c\ii-|-5,0){$S_{\ii}$};%to draw the inputs stimulus and their position
\draw[->,thick][blue] (E\ii)-- (Thalamus-c\ii);
\draw[->,thick] [red](Thalamus-c\ii) -- (Sensory Cortex-c\ii);
\draw[->,thick] [blue] (Sensory Cortex-c\ii) -- (Orbitofrontal Cortex-c\ii);
\draw[->,thick] [red] (Sensory Cortex-c\ii) -- (Amygdala-c\ii);
%\draw[->,thick] [red] (g) -- (Amygdala-c\ii);
}
\draw [->, thick] (Thalamus) |- (Amygdala-c5);
\end{tikzpicture}
\end{document}