相对于两个或多个节点对齐节点

相对于两个或多个节点对齐节点

我想要完成的可以在下图中看到。但是,我在对齐时遇到了问题

  • 具有敏感性和脆弱性的适应能力。
  • 气候变化和脆弱性的非气候因素
  • 适应与排放相结合的减缓

我到目前为止的代码是

\begin{tikzpicture}[node distance=0.6cm and 0.8cm]

\node [draw, minimum height=1 cm, minimum width = 12 cm, align=center] (vulnerability) {Vulnerability \\ to climate change};
\node [draw, above=of vulnerability.north west, anchor=north west, minimum height=1 cm, minimum width = 8 cm, yshift=1cm, align=center] (impacts) {Impacts \\ of climate change};
\node [draw, above=of impacts.north west, anchor=north west, minimum height=1 cm, minimum width = 3 cm, yshift=1cm, align=center] (exposure) {Exposure \\ to climatic stimuli};
\node [draw, above=of exposure.north west, anchor=north west, minimum height=1 cm, minimum width = 2 cm, yshift=1cm, align=center] (climate_change) {Climate \\ change};
\node [draw, above=of climate_change.north west, anchor=north west, minimum height=1 cm, minimum width = 2 cm, yshift=1cm, align=center] (concentrations) {Concen-\\trations};
\node [draw, above=of concentrations.north west, anchor=north west, minimum height=1 cm, minimum width = 2 cm, yshift=1cm] (emissions) {Emissions};
\node [draw,right=of climate_change, minimum height=1 cm, minimum width = 2 cm, align=center] (climate_variability) {Climate \\ variability};
\node [draw,right=of climate_variability, minimum height=1 cm, minimum width = 6 cm] (non-climatic_factors) {Non-climatic factors};

\node [right = of exposure] (identity_dot) {dot};

\node [draw, above=of impacts.north east, anchor=north east, minimum height=1 cm, minimum width = 2 cm, yshift=1cm] (sensitivity) {Sensitivity};
\node [draw, right=of sensitivity, minimum height=1 cm, minimum width = 2 cm, align=center] (adaptive_capacity) {Adaptive \\ Capacity};
\node [draw, right=of adaptive_capacity, minimum height=3.5 cm, minimum width = 2 cm, align=center, xshift=1cm] (adaption) {Adaption};
\node [draw, above=of adaption, minimum height=3 cm, minimum width = 2 cm, align=center] (mitigation) {Mitigation};



\end{tikzpicture}

我尝试过使用它\node [draw, right=of sensitivity -| vulnerability, minimum height=1 cm, minimum width = 2 cm, align=center] (adaptive_capacity) {Adaptive \\ Capacity}; 但是它似乎不起作用并且只是剪辑敏感度和适应能力。

任何帮助,将不胜感激

这就是代码产生的。

在此处输入图片描述

这就是我试图结束的

数字

答案1

最后,我使用了图书馆positioning
在此处输入图片描述

一些解释:

  • 主节点是sensitivity
  • (a|-b.east),其中(a)(b)为节点,表示 x 坐标为(a.center)、 y 坐标为 的点(b.east)
  • 样式是不言自明的,有助于使代码更清晰
  • 有一些幻影节点使得定位更容易(至少从我的角度来看)。

代码

\documentclass[11pt, margin=1cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{fit, arrows, positioning, arrows.meta}

\begin{document}
% https://tex.stackexchange.com/questions/581509/align-nodes-relative-to-two-or-more-nodes

\definecolor{G}{RGB}{0, 170, 128}

\tikzset{
  ph/.style={circle, inner sep=0pt},
  c/.style={draw, color=#1, fill=#1, circle, line width=2pt, inner sep=.1cm},
  sq/.style={draw, color=#1, line width=2pt, minimum height=1.25cm,
    minimum width=2.5cm, align=center, text=black},
  r/.style={draw, color=#1, line width=2pt,
    minimum width=2.5cm, align=center, rounded corners, text=black}
}
\tikzset{
  spear/.style={arrows={-Latex[length=5pt, width=8pt]},
    color=#1, very thick, shorten <=2pt, shorten >=2pt},
  string/.style={color=#1, very thick, shorten <=2pt}
}

\begin{tikzpicture}[node distance=.75cm and 1cm,
  every node/.style={text=black}]
  
  \node[sq={violet}] (sensitivity) {Sensitivity};
  \node[above=of sensitivity, ph] (phantom-c) {};
  \node[sq={orange}, right=of sensitivity, text width=2.2cm]
  (adaptivecapacity) {Adaptive capacity};
  \node[c={G}, left=of sensitivity] (gdot) {};

  \node[sq={G}, above=of phantom-c, minimum width=9.5cm]
  (factors) {Non-climatic factors};
  \node[sq={orange}, above=of factors, text width=2.2cm,
  yshift=1cm] (drivers) {Non-climatic drivers};
  \node[sq={G}, left=of factors, text width=2.2cm]
  (climatevariability) {Climate variability};
  \node[sq={violet}, left=of climatevariability, text width=2.2cm]
  (climatechange) {Climate change};

  \node[sq={violet}, above=of climatechange, text width=2.2cm]
  (concentrations) {Concen- trations};
  \node[sq={violet}, above=of concentrations] (emissions) {Emissions};
  \node[c={violet}, right=of emissions] (vdot) {};
  \node[c={orange}, right=of vdot, xshift=4.4cm] (odot) {};
  

  \node[sq={violet}, left=of gdot, minimum width=8.3cm]
  (exposure) {Exposure to climatic stimuli};
  \node[sq={violet}, below=of exposure,  minimum width=13.2cm, xshift=2.45cm]
  (impacts) {Impacts of climate change};
  \node[sq={G}, below=of impacts, minimum width=16.7cm, xshift=1.75cm]
  (vulnerability) {Vulnerability to climate change};

  \node[r={G}, right=of adaptivecapacity, minimum height=6.5cm, yshift=.55cm]
  (adaptation) {Adaptation};
  \node[r={violet}, above=of adaptation, minimum height=3.35cm]
  (mitigation) {Mitigation};
  \node[right=of adaptation, ph] (phantom-e) {};
  \node[right=of mitigation, ph] (phantom-ne) {};
  
  \path[spear={violet}] (emissions) edge (concentrations)
  (concentrations) edge (climatechange)
  (climatechange) edge (climatechange|-exposure.north)
  (exposure) edge (exposure|-impacts.north);
  
  \path[spear={G}] (impacts) edge (impacts|-vulnerability.north);
  \path[spear={G}] (climatechange) edge (climatevariability)
  (climatevariability) edge (climatevariability|-exposure.north);

  \path
  (factors) edge[spear={G}] (sensitivity)
  (sensitivity) edge[spear={violet}] (sensitivity|-impacts.north)
  (factors.south-|adaptivecapacity) edge[spear={orange}] (adaptivecapacity)
  (adaptivecapacity) edge[spear={orange}] (adaptivecapacity|-vulnerability.north)
  (drivers) edge[spear={orange}] (factors);

  \draw[string={G}] (vulnerability.east) -| (phantom-ne);
  \path[spear={G}] (phantom-e) edge (adaptation)
  (phantom-ne) edge (mitigation);

  \path[spear={violet}, dotted] (mitigation.west|-emissions.east) edge (emissions);
  \draw[spear={violet}, dotted] (vdot) |- (concentrations.east);
  
  \path[spear={orange}, dotted] (odot) edge (odot|-factors.north);

  \path[spear={G}, dotted] (gdot)
  edge (sensitivity)
  edge (exposure)
  edge (gdot|-impacts.north)
  edge (gdot|-factors.south);

  \draw[string={G}, dotted] (gdot) -- (sensitivity.west|-phantom-c)
  -- (phantom-c-|adaptation.west); 
\end{tikzpicture}
\end{document}

相关内容