水平树形图,左侧和右侧有节点

水平树形图,左侧和右侧有节点

我正在尝试绘制一个具有一个节点级别的树形水平树形图,这棵树有 13 个节点,所以我想通过跨越两侧(左侧和右侧)的节点而不是当前视图来利用空间。

\usepackage{tikz}
\usetikzlibrary{trees,positioning,shapes,shadows,arrows}
\begin{figure}
    \centering
    \begin{tikzpicture}[
every node/.style = {draw, rounded corners, fill=red!30,
    text width=18mm, minimum height=9mm, align=center,
    drop shadow},
             grow = right,
growth parent anchor=east,
level distance = 27mm,
sibling distance=10mm,
edge from parent path=(\tikzparentnode.east) -- (\tikzchildnode.west)
                        ]                    

% root of the the initial tree, level 1
\node[root] {\textbf{\textarabic{البرمجة كائنية التوجه}}}
% The first level, as children of the initial tree
  child {node[level-2] (c1) {\textbf{OOP}}}
  child {node[level-2] (c2) {\textbf{\textarabic{برمجة كائنية}}}}
  child {node[level-2] (c3) {\textbf{\textarabic{البرمجة كائنية التوجيه}}}}
  child {node[level-2] (c4) {\textbf{\textarabic{برمجة كانئية المنحى}}}}
  child {node[level-2] (c5) {\textbf{\textarabic{البرمجة كائنية التوجه}}}}
  child {node[level-2] (c6) {\textbf{\textarabic{برمجة كائنات موجهة}}}}
  child {node[level-2] (c7) {\textbf{\textarabic{شيئية المنحى}}}}
  child {node[level-2] (c8) {\textbf{\textarabic{برمجة كانئية المنحنى}}}}
  child {node[level-2] (c9) {\textbf{\textarabic{البرمجة الشيئية}}}}
  child {node[level-2] (c10) {\textbf{\textarabic{برمجه كائنيه التوجه}}}}
  child {node[level-2] (c11) {\textbf{\textarabic{برمجة غرضية التوجه}}}}
  child {node[level-2] (c12) {\textbf{\textarabic{برمجة موجهة}}}}  
  child {node[level-2] (c13) {\textbf{\textarabic{برمجة شيئية}}}};
\end{tikzpicture}
    \caption{Aliases for Object-Oriented Programming \href{https://www.wikidata.org/wiki/Q79872}{Q79872} in Wikidata in the Arabic language.}
    \label{ne_aliasies}
\end{figure}

上述代码的输出视图为: 在此处输入图片描述

我想要的是这样的: 在此处输入图片描述

答案1

在我看来,这是最接近您期望的,使用您原来的设计,但略作清理。请随意调整以满足您的需求。

左右两侧均生长树

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{trees,positioning,shapes,shadows,arrows.meta}

\begin{document}

    \begin{tikzpicture}[
        every node/.style = {
            draw,
            rounded corners,
            fill=red!30,
            text width=18mm,
            minimum height=9mm,
            align=center,
            drop shadow},
        >=Stealth,
        level distance = 30mm,
        sibling distance=13mm]
         
        \begin{scope}[grow'=right,edge from parent fork right,->]
            \node (root) at (0,0) {}
                child  {node (b1) {B1}}
                child  {node (b2) {B2}}
                child  {node (b3) {B3}};
         \end{scope}
         \begin{scope}[grow=left,edge from parent fork left,->]
            \node (root) at (0,0) {ROOT}
                child  {node (a1) {A1}}
                child  {node (a2) {A2}}
                child  {node (a3) {A3}};
             \end{scope}            
    \end{tikzpicture}
\end{document}

相关内容