TikZ, resizing and fitting

I want to take a PGF image, scale it (scaling the text so that \resizebox will be perfect) to get a certain height, then put the rotated text to the left of the image and create a node containing everything.

Something like that:

Algorithm example

But I want to be able to set the height of the chart without decreasing the rotated “name”.

Here is the LaTeX sample code for this example:

 \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning,fit,shapes.geometric,backgrounds} \begin{document} \begin{tikzpicture}[% inner sep=2mm, delimiter/.style={ellipse, very thick, fill=red!30, draw=red!50}, action/.style={trapezium, trapezium left angle=120, trapezium right angle=60, thick, fill=blue!30, draw=blue!50, align=center}, loop/.style={ellipse, thick, fill=yellow!30, draw=yellow!50, align=center}, title/.style={font=\LARGE\scshape,node distance=16pt, text=black!40, inner sep=1mm}, background/.style={rectangle, rounded corners, fill=black!5, draw=black!15, inner sep=4mm} ] \node[delimiter] (begin) {Begin}; \node[action] (cluster residues) [below=of begin] {Cluster residues}; \node[action] (set clusters) [below=of cluster residues] {Set properties\\for every cluster}; \node[action] (find pockets) [below=of set clusters] {Find clusters with\\$normalized\ SAS < 1$}; \node[action] (sort pockets) [below=of find pockets] {Sort pockets found}; \node[delimiter] (end) [below=of sort pockets] {End}; \draw[->] (begin.south) -- (cluster residues); \draw[->] (cluster residues) -- (set clusters); \draw[->] (set clusters) -- (find pockets); \draw[->] (find pockets) -- (sort pockets); \draw[->] (sort pockets) -- (end); \node[fit=(begin)(cluster residues)(set clusters)(find pockets)(sort pockets)(end)] (chart) {}; \node[title] (title) [left=of chart] {\rotatebox{90}{General algorithm}}; \begin{scope}[on background layer] \node[background,fit=(chart)(title)] {}; \end{scope} \end{tikzpicture} \end{document} 

Any ideas on how to use \resizebox , \adjustbox or anything else to resize just the chart (and not the General Algorithm label)?

+4
source share
1 answer

You can put the chart in scope and use the scale parameter to resize. Pay attention to the transform shape parameter. See Pgfmanual (17.7 Transformations) for more details.

enter image description here

 \documentclass[border=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{positioning,fit,shapes.geometric,backgrounds} \begin{document} \begin{tikzpicture}[% inner sep=2mm, delimiter/.style={ellipse, very thick, fill=red!30, draw=red!50}, action/.style={trapezium, trapezium left angle=120, trapezium right angle=60, thick, fill=blue!30, draw=blue!50, align=center}, loop/.style={ellipse, thick, fill=yellow!30, draw=yellow!50, align=center}, title/.style={font=\LARGE\scshape,node distance=16pt, text=black!40, inner sep=1mm}, background/.style={rectangle, rounded corners, fill=black!5, draw=black!15, inner sep=4mm} ] \begin{scope}[scale=0.5, transform shape] \node[delimiter] (begin) {Begin}; \node[action] (cluster residues) [below=of begin] {Cluster residues}; \node[action] (set clusters) [below=of cluster residues] {Set properties\\for every cluster}; \node[action] (find pockets) [below=of set clusters] {Find clusters with\\$normalized\ SAS < 1$}; \node[action] (sort pockets) [below=of find pockets] {Sort pockets found}; \node[delimiter] (end) [below=of sort pockets] {End}; \draw[->] (begin.south) -- (cluster residues); \draw[->] (cluster residues) -- (set clusters); \draw[->] (set clusters) -- (find pockets); \draw[->] (find pockets) -- (sort pockets); \draw[->] (sort pockets) -- (end); \end{scope} \node[fit=(begin)(cluster residues)(set clusters)(find pockets)(sort pockets)(end)] (chart) {}; \node[title] (title) [left=of chart] {\rotatebox{90}{General algorithm}}; \begin{scope}[on background layer] \node[background,fit=(chart)(title)] {}; \end{scope} \end{tikzpicture} \end{document} 
+2
source

All Articles