Radial node arrangement in Forest
This answer is based on How to combine a top-down and bottom-up binary tree in one picture?
It draws five trees, one each for the north
, east
, south
, west
and northwest
groups of cities. Each tree is saved using \savebox
. Each tree has customized growth directions and anchors to suit its design. For example, the north
tree uses grow'=north, child anchor=south, parent anchor=north
, and so on for each tree. For the tree growing north west, it may be necessary to play with the anchors to get a preferred arrangement of the nodes and edges. The individual trees are then drawn using \node
, and positioned using the positioning
library syntax. Each tree is connected to the root node, Kansas City
, using \draw
commands.
This is the result:
This is the MWE:
% http://tex.stackexchange.com/questions/213770/how-to-combine-a-top-down-and-bottom-up-binary-tree-in-one-picture
\documentclass[12pt,crop=true,border=1cm]{standalone}
\usepackage[edges]{forest}
\usepackage[none]{hyphenat}
\usetikzlibrary{shapes,positioning,arrows.meta,calc}
\tikzset{
mynodes/.style={inner sep=0pt,draw=none}
}
\forestset{
mytree/.style={
forked edges,
for tree={
draw,
rounded corners,
node options={align=center},
text width=2cm
}
}
}
\newsavebox\North
\newsavebox\East
\newsavebox\South
\newsavebox\West
\newsavebox\NorthWest
\savebox\North{\begin{forest}
mytree,
for tree={
child anchor=south,
parent anchor=north,
grow'=north,
anchor=south,
}
[North
[Minnesota]
[Wisconsin]
]
\end{forest}
}
\savebox\East{\begin{forest}
mytree,
for tree={
child anchor=west,
parent anchor=east,
grow'=east,
anchor=west,
}
[East
[South Carolina]
[North Carolina]
]
\end{forest}
}
\savebox\South{\begin{forest}
mytree,
for tree={
child anchor=north,
parent anchor=south,
grow'=south,
anchor=north,
}
[South
[Texas]
[Mexico]
]
\end{forest}
}
\savebox\West{\begin{forest}
mytree,
for tree={
child anchor=east,
parent anchor=west,
grow'=west,
anchor=east,
}
[West
[Los Angeles
[Santa Monica]
[West Hollywood]
]
[San Francisco
[The Castro]
]
]
\end{forest}
}
\savebox\NorthWest{\begin{forest}
mytree,
for tree={
child anchor=south east,
parent anchor=north west,
grow'=north west,
anchor=east,
}
[North West
[Portland]
[Seattle
[Redmond]
]
]
\end{forest}
}
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (Kansas) at (0,0) [shape=ellipse,x radius=2cm,draw,align=center] {Kansas City};
\node (North) [mynodes,above=of Kansas] {\usebox\North};
\node (East) [mynodes,right=of Kansas] {\usebox\East};
\node (South) [mynodes,below=of Kansas] {\usebox\South};
\node (West) [mynodes,left=of Kansas,xshift=3mm,yshift=-3mm] {\usebox\West};
\node (NorthWest) [mynodes,above left=1.85cm and 2.0cm of Kansas] {\usebox\NorthWest};
%
\draw[thick] (Kansas.north) -- (North.south);
\draw[thick] (Kansas.east) -- (East.west);
\draw[thick] (Kansas.south) -- (South.north);
\draw[thick] (Kansas.west) -- ++(-1.85,0) ;% (West.east);
\draw[thick] (Kansas.north west) -- ++(-2.2,1.9) ;% (NorthWest.south east);
\end{tikzpicture}
\end{document}
Conceptionally very similar to Ross' nice answer but instead of saveboxes I use Ulrike Fischers subnode trick. This allows one to connect the nodes rather than saveboxes. Still some manual adjustments necessary. EDIT: replaced the grow
s by grow'
such that north carolina is north of south carolina, and also added makeboxes to save some space.
\documentclass[border=5pt]{standalone}
\usepackage{forest}
\usetikzlibrary{tikzmark} % subnode trick from https://tex.stackexchange.com/a/393656/121799
\usepackage[LGR,T1]{fontenc} % these three lines added
\usepackage[utf8]{inputenc} % so that greek symbols will show
\begin{document}
\forestset{universal/.style={rounded corners=0.3em,
draw,rectangle,
minimum width=2.5em,
l sep+=1.5em,
s sep+=1em,
anchor=center,}
}
$
\begin{array}{ccc}
&\makebox[3.5cm][c]{\begin{forest}
for tree={
universal,
grow'=north
},
[\subnode{north}{north}
[wisconsin]
[minnesota]
]
\end{forest}} & \\
\vcenter{\hbox{\begin{forest}
for tree={
universal,
grow'=west
},
[\subnode{west}{west}
[los angeles,
[santa monica]
[west hollywood]
]
[san francisco,
[the castro]
]
]
\end{forest}}}
&
\vcenter{\hbox{\begin{forest}
for tree={
universal,
grow'=0
},
[\subnode{kansas}{kansas city}
]
\end{forest}}} &
\vcenter{\hbox{\begin{forest}
for tree={
universal,
grow'=east
},
[\subnode{east}{east}
[north carolina]
[south carolina]
]
\end{forest}}} \\
&
\makebox[3em][c]{\begin{forest}
for tree={
universal,
grow'=south
},
[\subnode{south}{south}
[texas]
[mexico]
]
\end{forest}}
&
\end{array}$
\begin{tikzpicture}[remember picture,overlay]
\draw (kansas) -- (north);
\draw (kansas) -- (west);
\draw (kansas) -- (south);
\draw (kansas) -- (east);
\end{tikzpicture}
\end{document}