3

I have created an image using tikz, but when scaling its size it is not coverting the coordinates appropiately, as you can see in the image below. I think its owing to using a lot of nodes to draw the images, particularly the orange and cyan lines, which are also the two that are not being scaled.

Scaling in Tikz

I am quite baffled right now, as other very similar images that I have created do scale properly. I know that I could use things such as resizebox, but I do not want the text to be scaled. I would really appreciate any help :)

A MWE is below:


\documentclass[IEEEtran]{standalone}
\usepackage{pgfplotstable} % Loads a bunch of packages
\pgfplotsset{compat=newest}
\usetikzlibrary{positioning}
\tikzstyle{help lines}=[thin,gray!40]
%- Define colors to be used 
\definecolor{Blue}{rgb}{0,0,1}%             
\definecolor{Cyan}{rgb}{0.0, 0.72, 0.92}%  
\definecolor{Orange}{rgb}{1.0, 0.49, 0.0}%   
%
\begin{document}
%

    \begin{tikzpicture}[scale=1]
    %- Axis node
    \node[inner sep=0,outer sep=0] (Origin Ax2) {};
        %- Axis
    \begin{scope}[-stealth,very thick]
        \draw (Origin Ax2)  -- +(0,3.5) node[anchor=south east,rotate=90] {Y axis}; % Y-axis
        \draw (Origin Ax2) -- +(4.75,0) node[anchor = north east]{X axis}; % X axis
    \end{scope}

    %- Blue line starting node
    \node[inner sep=0,outer sep=0,right=0.25 of Origin Ax2] (Blue Begins) {};
    %- Blue line
    \begin{scope}[color=Blue,very thick]
        \draw (Blue Begins) -- ++(0,3) node[anchor=north west]{Blue}  -- ++(3.5,0) -- ++(0,-3);
    \end{scope}

    %- Nodes to guide left and right side of the parabolas <- I think the problem might be here (?)
    \node[inner sep=0,outer sep=0,above=1.25 of Blue Begins] (Cyan left anchor) {};
    \node[inner sep=0,outer sep=0,right=3.5 of Cyan left anchor] (Cyan right anchor) {};
    \node[inner sep=0,outer sep=0,above=0.5 of Blue Begins] (Orange left anchor) {};
    \node[inner sep=0,outer sep=0,right=3.5 of Orange left anchor] (Orange right anchor) {};
    
    %- A label
    \node[below right= 0 and 1.5 of Blue Begins] (A) {A};
    \node[above=2.25 of A] (A top) {}; % Maximum of paraboles
    \begin{scope}[ dashed] % Line from (A) to (A top), but it appears waaay higher so modified by hand
        \draw (A) -- ++(0,2.8);
    \end{scope}
    
    %- Cyan line
    \begin{scope}[very thick, color=Cyan]
        \draw (A top) parabola ++(-1,-1) -- (Cyan left anchor); %Left side
        \draw  (A top) parabola ++(1,-1) node(DeltaAux){} -- (Cyan right anchor) node[anchor=north east]{Cyan}; % Right side
    \end{scope}
    
    %- Orange line
    \begin{scope}[very thick, color=Orange]
        \draw (A top) parabola ++(-0.5,-1.75) -- (Orange left anchor);
        \draw  (A top) parabola ++(0.5,-1.75) -- (Orange right anchor) node[anchor=north east]{Orange};
    \end{scope}
    
    %- Delta
    \begin{scope}
        \draw[dashed] (A top) -- +(2,0) node(DeltaTop){};
        \draw[dashed] (DeltaAux) -- +(1,0) node(DeltaBottom){};
        \draw[<->] (DeltaBottom) -- (DeltaTop) node[rotate = 90,midway, below]{$\Delta$};           
    \end{scope}

    \end{tikzpicture}
    
\end{document}

2
  • just add transform shape after scale: \begin {tikzpicture} [scale = 2, transform shape] ..., nodes ignore scaling without that declaration.
    – J Leon V.
    Jan 22, 2021 at 1:18
  • Transform shape also scales text, which is something that I would rather prevent
    – Jes
    Jan 22, 2021 at 6:13

1 Answer 1

1

Well, I found how to do it. As J Leon V said, nodes are not rescaled unless the key transform shape is used, but this also rescales the text. However, this only affects nodes declared with \node, but not nodes that are declared in the middle of a path/line. So, I modified the code so I declare the nodes that I need at the same time that I am creating the lines on the image.

It works properly now. Everything is scaled but the text remains where it should be, and with the size it should. I am posting the modification below, so it might serve as reference for other people :)

\documentclass[IEEEtran]{standalone}
\usepackage{pgfplotstable} % Loads a bunch of packages
\pgfplotsset{compat=newest}
\usetikzlibrary{positioning}
\tikzstyle{help lines}=[thin,gray!40]
%- Define colors to be used 
\definecolor{Blue}{rgb}{0,0,1}%           
\definecolor{Cyan}{rgb}{0.0, 0.72, 0.92}%  
\definecolor{Orange}{rgb}{1.0, 0.49, 0.0}%    
\begin{document}
%
    \begin{tikzpicture}[scale=1, on grid]
    %- Axis node
    \node[inner sep=0,outer sep=0] (Origin Ax2) {};

    %- Blue line
    \node[inner sep=0,outer sep=0,right=0.25 of Origin Ax2] (Blue Begins) {}; %Origin node of blue rectangle
    %- Blue line + A node
    \begin{scope}[color=Blue,very thick]
        \draw (Blue Begins) -- ++(0,3) node[anchor=north west]{Blue}  -- ++(3.5,0) -- ++(0,-3) --++ (-3.5,0) node[below, midway] (A){ \color{black} A};
    \end{scope}
    %- Dashed line from A to top
    \begin{scope}[ dashed] % Line from (A) to (A top)
            \draw (A) -- ++(0,2.8) node[below,inner sep=0,outer sep=0] (A top) {};
    \end{scope}

    %- Axis
    \begin{scope}[-stealth,very thick]
        \draw (Origin Ax2)  -- +(0,3.5) node[anchor=south east,rotate=90] {Y axis}; % Y-axis
        \draw (Origin Ax2) -- +(4.75,0) node[anchor = north east]{X axis}; % X axis
    \end{scope}

%   %- Nodes to guide left and right side of the parabolas <- I think the problem might be here (?)
%   \node[inner sep=0,outer sep=0,above=1.25 of Blue Begins] (Cyan left anchor) {};
%   \node[inner sep=0,outer sep=0,right=3.5 of Cyan left anchor] (Cyan right anchor) {};
%   \node[inner sep=0,outer sep=0,above=0.5 of Blue Begins] (Orange left anchor) {};
%   \node[inner sep=0,outer sep=0,right=3.5 of Orange left anchor] (Orange right anchor) {};

    %- Cyan line
    \begin{scope}[very thick, color=Cyan]
        \draw (A top) parabola ++(-1,-1) -- ++(-0.75,0); %Left side
        \draw  (A top) parabola ++(1,-1) node(Cyan){} -- ++(0.75,0) node[midway,below]{Cyan}; % Right side
    \end{scope}

    %- Orange line
    \begin{scope}[very thick, color=Orange]
        \draw (A top) parabola ++(-0.5,-1.75) -- ++(-1.25,-0.5);
        \draw  (A top) parabola ++(0.5,-1.75) -- ++(1.25,-0.5) node[midway, below]{Orange};
    \end{scope}

    %- Delta
    \begin{scope}
        \draw[dashed] (A top) -- +(2,0) node(DeltaTop){};
        \draw[dashed] (Cyan) -- +(1,0) node(DeltaBottom){};
        \draw[<->] (DeltaBottom) -- (DeltaTop) node[rotate = 90,midway, below]{$\Delta$};           
    \end{scope}

    \end{tikzpicture}
    
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .