如何重新调整整个图表的比例?

如何重新调整整个图表的比例?

这是我的图表代码。我想重新调整整个图表的比例,以便将其正确放入我的演示幻灯片中。我不知道如何重新调整它的比例。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows,
                positioning,    % <--- added
                shapes}
\usepackage{xparse}% So that we can have two optional parameters
\NewDocumentCommand\DownArrow{O{2.0ex} O{black}}%
{%
\mathrel{\tikz[baseline] \draw [<-, line width=0.5pt, #2] (0,0) -- ++(0,#1);}
}

\begin{document}
    \begin{tikzpicture}[
        node distance = 3mm and 12mm,
        block/.style = {rectangle, draw, rounded corners, text width =15em, align=center},
        cloud/.style = {draw, ellipse, aspect=1.2, align=center},]
    % Place nodes
        \node [block, label={[anchor=east, align=center, xshift=-1em,
                      font=\small\linespread{0.8}\selectfont, 
                      text=purple]right:
                $x_1,\dotsc,x_n$:\\
                 features\\ 
                 variables} 
                ] (init) {\underline{Machine}\\
                 $f(\vec{x}) = \theta_0 + \theta_1 x_1 + \dotsm + \theta_n x_n$\\[1ex]
                 $\DownArrow[30pt]$\\[1ex]
                 $y=\phi\bigl(f(\vec{x})\bigr)$
                 };
        \node [cloud, left=of init] (data)
                 {\underline{Training data set}\\
                  dog, cat, pig, etc};
        \node [cloud, above right=of init.east] (input)
                 {\underline{Input}\\
                  features data $\vec{x}$};
        \node [cloud, below right=of init.east] (output)
                  {\underline{Output}\\
                   class: $y$};
        % Draw edges
        \draw[-latex']  (data) -- (init);
        \draw[red,-latex']  (input) -- (init.east |- input);
        \draw[red,-latex']  (init.east |- output) -- (output);
    \end{tikzpicture}
\end{document}

答案1

万一您用于演示,请查看我提供的答案中beamer指出的以下小变化(% <---这样的流程图该怎么画呢?) 对您而言是可以接受的:

在此处输入图片描述

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows,
                positioning,
                shapes}
\usepackage{xparse}% So that we can have two optional parameters
\NewDocumentCommand\DownArrow{O{2.0ex} O{black}}%
{%
\mathrel{\tikz[baseline] \draw [<-, line width=0.5pt, #2] (0,0) -- ++(0,#1);}
}

\begin{document}
\begin{frame}
\frametitle{My diagram}
    \begin{tikzpicture}[
node distance = 7mm and 4mm,                                  % <---
 block/.style = {rectangle, draw, rounded corners, align=center},
 cloud/.style = {draw, ellipse, inner sep=1pt, align=center}, % <---
         font = \footnotesize                                 % <---
                    ]
% Place nodes
\node [block, label={[anchor=east, align=center, xshift=-1ex, % <---
                      font=\scriptsize\linespread{0.9}\selectfont,% <---
                      text=purple]right:
                $x_1,\dotsc,x_n$:\\
                 features\\
                 variables}
       ] (init) {\underline{Machine}\\
                 $f(\vec{x}) = \theta_0 + \theta_1 x_1 + \dotsm + \theta_n x_n$\\[1ex]
                 $\DownArrow[24pt]$\\[1ex]                    % <---
                 $y=\phi\bigl(f(\vec{x})\bigr)$
                 };
\node [cloud, left=of init] (data)
                 {\underline{Training data set}\\
                  dog, cat, pig, etc};
\node [cloud, above right=of init.east, anchor=west] (input)  % <---
                 {\underline{Input}\\
                  features\\ data $\vec{x}$};                 % <---
\node [cloud, below right=of init.east, anchor=west] (output) % <--- 
                  {\underline{Output}\\
                   class: $y$};
% Draw edges
\draw[-latex']  (data) -- (init);
\draw[red,-latex']  (input) -- (init.east |- input);
\draw[red,-latex']  (init.east |- output) -- (output);
    \end{tikzpicture}
\end{frame}
\end{document}

相关内容