# How to resize a figure?

I am trying to resize the following figure. I have produced for one document. Now I want to re-use the code in another document, but I need to make the figure smaller. I have tried many re-sizing commands and even using minipage (in different parts of the code), but nothing worked. I really appreciate your help.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{pgf,tikz}
\usetikzlibrary{positioning,calc,chains,fit,shapes,arrows}
\begin{document}
\begin{figure}
\begin{center}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1}
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\draw [color=cqcqcq,, xstep=1cm,ystep=1cm] (-1.52,-1.25) grid (7.52,7.25);
\clip(-1.52,-1.25) rectangle (6.52,6.25);
\draw [line width=2pt] (3,3) circle (2.8cm);
\draw [->,line width=2pt] (3,3) -- (5.669424238929763,3.845088298708634);
\draw (3.58,4.02) node[anchor=north west] {$\sqrt n$};
\draw (1,6) node[anchor=north west] {$C$};
\draw[thick,->] (-1,3) -- (6.5,3) node[anchor=north west] {};
\draw[thick,->] (3,-1) -- (3,6.2) node[anchor=south east] {};
\begin{scriptsize}
\draw [fill=ududff] (3,3) circle (2.5pt);
\draw [fill=xdxdff] (5.669424238929763,3.845088298708634) circle (2.5pt);
\end{scriptsize}
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}

• Have you looked into the \resizebox and \scalebox commands that are provided by the graphicx package? – Mico Apr 24 '18 at 15:17
• Normally, I would use the x=… and y=… options to adapt the figure to the size I want, but here, I note a mix of numbers with an without units in your code, so changing the x and y values would probably break your figure. But if you clean that up first, it may be the way to go. – Harald Hanche-Olsen Apr 24 '18 at 15:21
• Thanks very much to both. They are good ideas. I ended applying Mico's suggestion and worked. – orient Apr 24 '18 at 15:50

I have a hunch that \scalebox and \resizebox -- both macros are provided by the graphicx package -- are what you're looking for. The former macro scales its main argument by a factor, relative to the "natural size" of the object. The latter macro scales its main argument to an absolute size.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx,amsmath}
\usepackage{pgf,tikz}
\usetikzlibrary{positioning,calc,chains,fit,shapes,arrows}

\definecolor{xdxdff}{rgb}{0.490,0.490,1}
\definecolor{ududff}{rgb}{0.302,0.302,1}
\definecolor{cqcqcq}{rgb}{0.753,0.753,0.753}
\newcommand\mypic{%
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45, x=1cm, y=1cm]
\draw [color=cqcqcq,, xstep=1cm, ystep=1cm] (-1.52,-1.25) grid (7.52,7.25);
\clip(-1.52,-1.25) rectangle (6.52,6.25);
\draw [line width=2pt] (3,3) circle (2.8cm);
\draw [->,line width=2pt] (3,3) -- (5.669,3.845);
\draw (3.58,4.02) node[anchor=north west] {$\sqrt n$};
\draw (1,6) node[anchor=north west] {$C$};
\draw[thick,->] (-1,3) -- (6.5,3) node[anchor=north west] {};
\draw[thick,->] (3,-1) -- (3,6.2) node[anchor=south east] {};
\begin{scriptsize}
\draw [fill=ududff] (3,3) circle (2.5pt);
\draw [fill=xdxdff] (5.669,3.845) circle (2.5pt);
\end{scriptsize}
\end{tikzpicture}}

\begin{document}
\begin{figure}
\centering
\mypic % no scaling, i.e., display pic at its "natural" size

\scalebox{0.25}{\mypic} % scale down to 1/4 of natural size

\resizebox{5cm}{!}{\mypic} % "!" means: vertical scale same as horiz. scale
\end{figure}
\end{document}