用图像替换矩形节点,使文字标题清晰易读

用图像替换矩形节点,使文字标题清晰易读

我想用下面 MWE 中的图像替换矩形,用描绘数据的图像替换第二个数据,例如

我尝试过(如第一个矩形中的 MWE),但它仍然不能完美地工作。矩形中的文字可能会出现在图像下方。

同样,我希望矩形内的文字清晰易读——每次我将此图下载为 PDF 并在其他LaTeX文档中使用它时,图中的文字都会变得模糊。我想知道是否有任何方法可以让文章中的图表非常清晰易读?


\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{arrows,positioning,shapes}
\usepackage{amsfonts} 
\usetikzlibrary{calc} 
\begin{document}
    \begin{tikzpicture}[node distance=25mm, >=latex',
        block/.style = {draw, rectangle, minimum height=10mm, minimum width=17mm,align=center,fill=green!20!yellow!40!, line width=0.5pt},
        rblock/.style = {draw, rectangle, rounded corners=0.5em},
        tblock/.style = {draw, trapezium, minimum height=10mm, 
            trapezium left angle=75, trapezium right angle=105, align=center},
        ]

        \node [block]                      (start)      {\includegraphics[width=1cm]{example-image-a}\\Function\\ $k(\cdot)$};
        \node [block, right=of start]    (combined)   {First. Data + \\ Second. Data};
        \node [block, above=of combined]     (ref)  {Second Data};
        \node [block, right=of combined]     (detecting) {Training \\ Data};
        
        \node [block, right=of detecting]     (Train) {Train Set};
        \node [block, above =of Train]  (validation)     {Validation};

        \node [block, right=of Train]  (final)     {Function \\ (Re)training};
        \node [block, above = of final]  (checker)     { Check   cycle};



        % Paths with text
        \path[draw,->,line width=0.9pt] (start)      edge node[midway, above,shorten <=0.1mm] {\parbox{1.5cm}{Generate first data \\  samples}} (combined)
                      
                       (ref)   edge node[midway, right] { } (combined)
                       
                       (combined)    edge node[midway, above] {\parbox{1.5cm}{reshuffle  \\  data}} (detecting)
                       
                       (detecting)  edge node[midway, below] { \parbox{1.5cm}{split training \\  data} } (Train)

                        (checker)  edge node[midway, above] {} (final)
                        (final)  edge node[midway, above] {} (checker)

                        (validation)  edge node[midway, above] {} (checker)

                        (Train)  edge node[midway, above] {} (final);

                       
                       % (Train)  edge node[midway, above] {} (final);
                

                   \draw[->,line width=0.9pt] (final.south) -- ++(0,-1.5cm) -- ++(-18.2cm,0) node[midway, below] {\parbox{7.5cm}{After every $(3k)$-th training epoch, $k \in \mathbb{N}$}} |- (start.south);

                
            \draw[->,line width=0.9pt] ([xshift=10mm]detecting.east) |- ($(validation.west)!0.0!(validation.west)$);
      
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

  • 正如@cfr 在她的评论中提到的,你的问题是什么?
  • 看来,下面的建议大多都是题外话……
\documentclass[margin=3mm]{standalone}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc, chains,
                ext.paths.ortho,    % defined in the tikz-ext package                
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
node distance = 25mm, 
  start chain = A going right,
   arr/.style = {-Latex, semithick},
 block/.style = {minimum height=12mm, font=\small, 
                 text width=21mm, align=center, inner sep=1pt},
every edge quotes/.style = {auto, text width=21mm, align=center, 
                            font=\footnotesize}
                        ]
\setkeys{Gin}{width=16mm}
% nodes
    \begin{scope}[nodes={block, on chain=A, join = by arr}]
\node   {\includegraphics{example-image-a}\\
         Function\\ $k(\cdot)$};
\node   {\includegraphics{example-image-b}\\
         First. Data + \\ Second. Data};
\node   {\includegraphics{example-image-c}\\
         Training \\ Data};
\node   {\includegraphics{example-image-duck}\\
         Train\\ Set};
\node   {\includegraphics{example-image}\\
         Function \\ (Re)training};
    \end{scope}
\node [block, draw, above=of A-2]  (ref)        {Second Data};
\node [block, draw, above=of A-4]  (val)        {Validation};
\node [block, draw, right=of val]  (checker)    {Check cycle};
% Paths with text
\path   (A-1) to ["Generate first data samples"]    (A-2)
        (A-2) to ["reshuffle\\ data"]                 (A-3)
        (A-3) to ["split training data" ']          (A-4);
\draw[arr]  (ref) edge  (A-2)
            (val) edge  (checker)
            (A-5) edge  (checker)
            ($(A-3)!0.5!(A-4)$) |- (val);
\draw[->]   (A-5) r-du  (A-1) node[midway, below, font=\footnotesize]
                                {After every $(3k)$-th training epoch, $k \in \mathbb{N}$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

tikz.ext 点击此处下载CTAN:tikz-ext.然后tikzlibraryext.paths.ortho.code.tex从下载的文件夹上传到相应的项目文件夹。

相关内容