如何在此 Tikz 图中添加水平、垂直、对角线和曲线边缘?

如何在此 Tikz 图中添加水平、垂直、对角线和曲线边缘?

如何使用 Tikz 绘制这幅图?在此处输入图片描述

此处提供了使用 Zarko 解决方案的 MWE绘制下面的图?


    \documentclass[12pt, a4paper]{report}
    
    \usepackage{tikz}
    \usetikzlibrary{arrows.meta, positioning, quotes}
    
    \begin{document}
       \begin{figure} \centering
      \begin{tikzpicture}[
    node distance = 33mm and 33mm,
         N/.style = {draw, minimum size=12mm, inner sep=0pt},
                > = {Stealth[scale=0.6]},
     every edge/.append style = {draw, ->},
    every edge quotes/.append style = {font=\small\linespread{0.75}\selectfont,
                                       inner sep=5pt, sloped}
                            ]
    \node [N] (A) {$S$};
    \node [N, right=of A] (B) {$A$};
    \node [N,below=of B] (C) {$I$};
    \node [N,left=of C] (D) {$R$};
    %
    \draw [<-] (A) -- ++(-1,0) node[left] {$b\left(1-\nu\right)$};
    \draw [<-] (D) -- ++(-1,0) node[left] {$b\nu$};
    \draw [->] (A) -- ++(0,1) node[above] {$\mu S$};
    \draw [->] (B) -- ++(0,1) node[above] {$\mu A$};
    \draw [->] ([xshift=-3.5mm] C.south) -- ++(0,-0.4) node[below] {$\alpha I$};
    \draw [->] ([xshift=+3.5mm] C.south) -- ++(0,-0.4) node[below] {$\mu I$};
    \draw [->] (D) -- ++(0,-1) node[below] {$\mu R$};
    \draw[->] (B)--(D) node[midway,sloped,above]{$\gamma_A$};
    %
    \end{tikzpicture}
    \setlength{\textfloatsep}{10pt plus 1.0pt minus 2.0pt}
    \caption{Flow diagram for the SAIRS model.}
    \end{figure}
        \end{document}

请随意改进这个 MWE。

答案1

tikz-cd以下是使用 和的解决方案circledsteps

    \documentclass[pdf]{article}
    \usepackage{mathtools}
    \usepackage{tikz-cd, circledsteps}

    \begin{document}

    \[ \begin{tikzcd}[column sep=large, row sep=large]
     & \mu & \mu \\
    \arrow[r, "b(1-\nu)"] &\Circled{S} \arrow[r, "(\beta_AA + \beta_I I)"] \arrow[u]\arrow[d, shift right=0.75ex, "\rho", swap]& \Circled{A} \arrow[u]\arrow[ld, "\delta u", swap] \arrow[d, "\nu"]\\%
    \arrow[r, "b\nu"] &\Circled{R}\arrow[d]\arrow[u, shift right=0.75ex, "\epsilon", swap] & \Circled{I}\arrow[l, "\delta_I", swap]\arrow[d] \arrow[l, bend left, "\tau"]\\
    & \mu & \mu + \alpha
    \end{tikzcd}
    \]

    \end{document}

在此处输入图片描述

答案2

您对这个简单的 TikZ 代码有什么看法?请更新更清晰的手绘 ^^ PS:我稍后会完成图表。

在此处输入图片描述

\documentclass[12pt, a4paper]{report}
\usepackage{tikz}
\begin{document}
\begin{figure} 
\centering
\begin{tikzpicture}[>=stealth,thick]
\def\a{4}
\path[nodes={circle,draw,minimum size=12mm}]
(0,0)   node[fill=yellow] (R) {$R$}
(\a,0)  node[fill=red]    (I) {$I$}
(\a,\a) node[fill=cyan]   (A) {$A$}
(0,\a)  node[fill=green]  (S) {$S$}
;
\draw[->] (A)--(R) node[midway,sloped,above]{$\delta_a$};
\draw[->] (I)--(R) node[midway,above]{$\delta_I$};
\draw[->] (I.-135) to[bend left] node[midway,below]{$\tau$} (R.-45);
\draw[->] (S)--+(0,1.5) node[above]{$\mu$};
\draw[<-] (S)--+(-2,0) node[above]{$b(1-\mu)$};
\end{tikzpicture}
\caption{Flow diagram for the SAIRS model.}
\end{figure}
\end{document}

相关内容