[Tex/LaTex] Transform Shape not working – TikZ

tikz-pgftikzscale

I'm trying to scale the whole picture but it's not working.

\begin{tikzpicture} [scale=0.5, every node/.style={transform shape}]

\tikzstyle{startstop}   = [ellipse,   draw=orange, thick, fill=orange!20, text width=5em, minimum height=4em, text centered, dashed]
\tikzstyle{block}       = [rectangle, draw=blue,   thick, fill=blue!20,   text width=8em, minimum height=4em, shape aspect=2, text centered, rounded corners]

    % Define nodes in a matrix
    \matrix [column sep=10mm, row sep=7mm]
            {
                \node   [startstop]     (Signal)        {Trama de la señal};
                &\node  [block]         (DFT)           {Transformada Discreta de Fourier};
                &\node  [block]         (Module)        {Módulo};
                &\node  [block]         (MelFilt)       {Filtros Mel}; \\
                \node   [startstop]     (MFCC)          {MFCC};
                &\node  [block]         (Lifter)        {Lifter};
                &\node  [block]         (IDCT)          {Transformada Discreta Inversa de Coseno};
                &\node  [block]         (Log)           {Logaritmo}; \\
            };

    \node [draw, scale=1, rectangle, dashed, thick, fit=(DFT) (Module) (Log) (Lifter) (IDCT)] {};

    % connect all nodes DFT above
    \begin{scope} [every path/.style={line, line width=1.3pt}  ]

        %Down Lines 
        \path (Signal)  --  (DFT);
        \path (DFT)     --  (Module);
        \path (Module)  --  (MelFilt);
        \path (MelFilt.south)   --  (Log.north);
        \path (Log)     --  (IDCT);
        \path (IDCT)    --  (Lifter);
        \path (Lifter)  --  (MFCC);

    \end{scope}

\end{tikzpicture}

And when I replace transform shape for scale=0.5, the fitting fails.

Best Answer

I think the issue is the matrix. As soon as I switched to regular nodes, it started working better. I also don't think a matrix is the appropriate tool here since it works a bit differently. Alternatively, I'd suggest using the chains library which will also get rid of the extra line commands below. Finally, you can remove the fit library and use calc to draw a fitting rectangle around the nodes (you only needed two by the way for fitting them).

Of course, now it scales better!

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{shapes.geometric, chains, calc}

\tikzset{
    startstop/.style={ellipse,   draw=orange, thick, fill=orange!20, text width=5em, minimum height=4em, text centered, dashed},
    block/.style={rectangle, draw=blue,   thick, fill=blue!20,   text width=8em, minimum height=4em, shape aspect=2, text centered, rounded corners},
    links/.style={line width=1.3pt}
}

\begin{document}
\begin{tikzpicture}[scale=.5,transform shape,
    start chain=going right, node distance=1cm, auto,
    every join={line width=1.3pt},
    every node/.style={on chain, join}
    ]

% Define nodes in a matrix
\node[startstop] (Signal)  {Trama de la señal};
\node[block]     (DFT)     {Transformada Discreta de Fourier};
\node[block]     (Module)  {Módulo};
\node[block]     (MelFilt) {Filtros Mel};
\node[continue chain=going below,block] (Log) {Logaritmo};
\node[continue chain=going left, block] (IDCT) {Transformada Discreta Inversa de Coseno};
\node[continue chain=going left, block]     (Lifter)  {Lifter};
\node[continue chain=going left, startstop] (MFCC)    {MFCC};

% connect all nodes DFT above
\draw[dashed, thick, rounded corners] ($(Lifter.south west)+(-.2,-.2)$) rectangle ($(MelFilt.north east)+(.2,.2)$);

\end{tikzpicture}
\end{document}