框图连接

框图连接

我想连接一些不同尺寸的图表并改变线条的样式:

在此处输入图片描述

我想将红色圆圈线改为虚线,并将其从两个块的侧面连接起来,而不是从一个块的侧面连接到另一个块的底部。深色圆圈线也是一样。以下是该图的代码:

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage{tikz}  
\usepackage{mathtools}  
\usepackage{amsmath}
\usepackage{amssymb} 
\usetikzlibrary{shapes,arrows, positioning, calc} 

% \usetikzlibrary{shapes,arrows}    

% \usetikzlibrary{positioning}  
% \usepackage{subfig} 
% \usepackage{geometry} 
\usepackage{float}

\title{Diagramas} 
\author{}
\date{}

% Modificaciones 
\tikzstyle{block} = [draw, fill=white, rectangle, 
    minimum height=3em, minimum width=6em   ]

\begin{document}

\maketitle 

\begin{figure}[H]\centering 
\hspace*{-3cm}
\begin{tikzpicture}[auto, node distance=2cm,>=latex',anchor=center]
%Declara los nodos 

% Producto final
\node[block, fill = gray!50] (system) {$\begin{array}{cc} \text{\textbf{Sistema de}}\\ \text{\textbf{Bola Balanza}} \end{array}$};       

% Nivel 7
\node[block, below of = system, fill = gray!50, left = 5cm] (dis_soft){$\begin{array}{cc} \text{\textbf{Diseño}}\\ \text{\textbf{del software}} \end{array}$}; 

\node[block, below of = system, fill = gray!50, right = 4cm] (model){\textbf{Modelado}};

% Nivel 6
\node[block, below of = dis_soft, fill = gray!50, left = -1.65cm] (prom_control){$\begin{array}{cc} \text{\textbf{Programación}}\\ \text{\textbf{del controlador}} \end{array}$};  

% Nivel 5 
\node[block, below of = prom_control, fill = gray!50, left = 1.65cm] (prom_plant){$\begin{array}{cc} \text{\textbf{Programación}}\\ \text{\textbf{de la planta}} \end{array}$};  

\node[block, below of = prom_control, fill = gray!50, right = 1cm] (dis_control){$\begin{array}{cc} \text{\textbf{Diseño}}\\ \text{\textbf{del controlador}} \end{array}$};

% Nivel 4 
\node[block, below of = dis_control, fill = gray!50, right = 7.3cm] (ident_sis){$\begin{array}{cc} \text{\textbf{Identificación}}\\ \text{\textbf{del sistema}} \end{array}$}; 

% Nivel 3 
\node[block, below of = ident_sis, fill = gray!50, left = 3.8cm] (plant_dis){$\begin{array}{cc} \text{\textbf{Diseño de }}\\ \text{\textbf{la planta}} \end{array}$}; 

% Nivel 2 
\node[block, below of = plant_dis, fill = gray!50, right = 3.8cm] (analisis_mat){$\begin{array}{cc} \text{\textbf{Análisis}}\\ \text{\textbf{matemático}} \end{array}$}; 

\node[block, below of = plant_dis, fill = gray!50, left = 3.8cm] (dis_cad){$\begin{array}{cc} \text{\textbf{Diseño}}\\ \text{\textbf{de CAD}} \end{array}$}; 

\node[block, below of = plant_dis, fill = gray!50, left = 7cm] (prom_elem){$\begin{array}{cc} \text{\textbf{Programación de}}\\ \text{\textbf{cada elemento}} \end{array}$};

% Nivel 1 
\node[block, below of = dis_cad, fill = gray!50, left = -1.05cm] (mat){\textbf{Materiales}};

%Ahora conectamos los bloques  
% Nivel 7
\draw[-] (system) -| (dis_soft);
\draw[-] (system) -| (model);   
% Nivel 6
\draw[-] (dis_soft) -- (prom_control); 
% Nivel 5
\draw[-] (prom_control) -| (dis_control); 
\draw[-] (dis_soft) -| (prom_plant);  
\draw[-] (dis_control) -| (model);
% Nivel 4 
\draw[-] (model) -- (ident_sis);    
% Nivel 3
\draw[-] (system) -- (plant_dis); 
\draw[-] (plant_dis) -| (prom_plant); 
\draw[-] (plant_dis) -| (ident_sis); 
% Nivel 2 
\draw[-] (model) -| (analisis_mat); 
\draw[-] (dis_cad) -| (plant_dis); 
% Nivel 1 
\draw[-] (mat) -- (dis_cad); 
\draw[-] (mat) -| (analisis_mat);


\end{tikzpicture} 
\caption{Estructura de todo el sistema}
\end{figure} 

我很感谢你的帮助。

答案1

像这样?

在此处输入图片描述

\documentclass[border=3.14]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}
\usepackage{amsmath}

\begin{document}
    \begin{tikzpicture}[
            > = Latex,
node distance = 8 mm and 4 mm, 
 block/.style = {draw, fill = gray!50, font=\bfseries, align=center,
                 minimum height=3em, minimum width=7em} %<---
                        ]
%Declara los nodos
% Producto final
    \begin{scope}[nodes=block]
\node (system)      {Sistema de\\ Bola Balanza};
% Nivel 7
\node (dis_soft)    [below  left=11mm and 22mm of system] {Diseño\\ del software};
\node  (model)      [below right=11mm and 22mm of system] {Modelado};
% Nivel 6
\node (prom_cntrl)  [below=of dis_soft]     {Programación\\ del controlador};
% Nivel 5
\node (prom_plant)  [below left =of prom_cntrl.south]   {Programación\\ de la planta};
\node (dis_control) [below right=of prom_cntrl.south]   {Diseño\\ del controlador};
% Nivel 4
\node (ident_sis)   [below=of model |- prom_cntrl.south]     {Identificación\\ del sistema};
% Nivel 3
\node (plant_dis)   [below=of dis_control.south -| system]     {Diseño de\\ la planta};
% Nivel 2
\node (analisis_mat)[below=of plant_dis -| ident_sis]  {Análisis\\ matemático};
% Nivel 1
\node (dis_cad)     [below left = of plant_dis]         {Diseño\\ de CAD};
\node (prom_elem)   [left= of dis_cad]                  {Programación de\\ cada elemento};
% Nivel 0
\node (mat)         [below= of dis_cad]                 {Materiales};
    \end{scope}

% Ahora conectamos los bloques
\draw   (system)    -| (dis_soft) 
        (system)    -| (model) 
        (system)    -- (plant_dis)
%       
        (dis_soft)  -| (prom_plant)
        (dis_soft)  -- (prom_cntrl)
        (model.east) -- + (1,0) |- (analisis_mat)
% 
        (prom_cntrl) -| (dis_control)
%
        (prom_plant) |- (plant_dis) -| (ident_sis)
        (plant_dis)  |- (dis_cad)   -- (mat) -| (analisis_mat);
\draw[densely dotted]
        (model.west) -- ++ (-1,0) |- ([yshift=+1ex] dis_control) %<---
        (analisis_mat.west) -- ++ (-1,0) |- ([yshift=-1em] dis_control); %<---
    \end{tikzpicture}
\end{document}

正如您所注意到的,通过使用定义的节点样式和在模式放置处使用的定位语法,图像代码非常短。

答案2

这对你有用吗?我还擅自简化了一些事情,以便于处理。

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage{tikz}  
\usepackage{mathtools}  
\usepackage{amsmath}
\usepackage{amssymb} 
\usetikzlibrary{shapes,arrows, positioning, calc} 
\usepackage{float}

\title{Diagramas} 

% Modificaciones 
\tikzstyle{block} = [draw, fill=gray!50, rectangle, minimum height=3em, minimum width=6em, font=\bfseries, align=center]

\begin{document}
    
    \maketitle 
    
    \begin{figure}[H]\centering 
        \hspace*{-3cm}
        \begin{tikzpicture}[auto, node distance=2cm,>=latex',anchor=center]
        %Declara los nodos 
        
        % Producto final
        \node[block] (system) {Sistema de\\Bola Balanza};
        
        % Nivel 7
        \node[block, below of = system, left = 5cm] (dis_soft){Diseño\\del software};
        \node[block, below of = system, right = 4cm] (model){Modelado};
        
        % Nivel 6
        \node[block, below of = dis_soft] (prom_control){Programación\\del controlador};
        
        % Nivel 5 
        \node[block, below of = prom_control, left = 1.65cm] (prom_plant){Programación\\de la planta};
        
        \node[block, below of = prom_control, right = 1cm] (dis_control){Diseño\\del controlador};
        
        % Nivel 4 
        \node[block, below of = model, below = 4cm] (ident_sis){Identificación\\del sistema};
        
        % Nivel 3 
        \node[block, below of = system, below = 8cm] (plant_dis){Diseño de\\la planta}; 
        
        % Nivel 2 
        \node[block, below of = plant_dis, right = 3.8cm] (analisis_mat){Análisis\\matemático}; 
        \node[block, below of = plant_dis, left = 3.8cm] (dis_cad){Diseño\\de CAD};
        \node[block, below of = plant_dis, left = 7cm] (prom_elem){Programación de\\cada elemento};
        
        % Nivel 1 
        \node[block, below of = dis_cad, left = -1.05cm] (mat){Materiales};
        
        %Ahora conectamos los bloques  
        % Nivel 7
        \draw[-] (system) -| (dis_soft);
        \draw[-] (system) -| (model);   
        % Nivel 6
        \draw[-] (dis_soft) -- (prom_control); 
        % Nivel 5
        \draw[-] (prom_control) -| (dis_control); 
        \draw[-] (dis_soft) -| (prom_plant);
        \path[-] (dis_control) -| node[pos=.35, name=A] {} (model); % new one
        \draw[dashed] (dis_control) -- (A.center);
        \draw[dashed] (model.west) -| (A.center);
        \draw[dashed] (ident_sis.west) -| (A.center);
        % Nivel 4 
        \draw[-] (model) -- (ident_sis);    
        % Nivel 3
        \draw[-] (system) -- (plant_dis); 
        \draw[-] (plant_dis) -| (prom_plant); 
        \draw[-] (plant_dis) -| (ident_sis); 
        % Nivel 2 
        \coordinate[right of=ident_sis] (B);    % new one
        \draw[dashed] (model.east) -| (B.center);
        \draw[dashed] (analisis_mat) -| (B.center); 
        \draw[-] (dis_cad) -| (plant_dis); 
        % Nivel 1 
        \draw[-] (mat) -- (dis_cad); 
        \draw[-] (mat) -| (analisis_mat);
        
        
        \end{tikzpicture} 
        \caption{Estructura de todo el sistema}
    \end{figure} 
\end{document} 

在此处输入图片描述

相关内容