1

Using pgfplots, externalize an .avi file and using DVI>ps, externalize an .eps file on A4 but I want a figure with width and height of 10cm in letter (10cm x 10cm). How can I make it?

(If you know how to make a figure that be equal the page size.)

this is my code.

\documentclass{report}‎
‎\usepackage{pgfplots}‎
‎\usepgfplotslibrary{external}‎
‎\tikzexternalize{question}‎
‎\setlength{\pdfpagewidth}{15 cm}‎ 
‎\setlength{\pdfpageheight}{15 cm}‎ 
‎\newpage‎
‎\thispagestyle{empty}‎
‎\begin{document}‎
‎\pgfplotsset{width=10cm,height=10cm}‎
‎\begin{tikzpicture}‎
 ‎\begin{axis}[‎
   ‎xlabel={$x$}‎,
   ‎ylabel={\textbf{ $f(x)$‎ }}
   ]
   ‎\addplot {x^2};‎
   ‎\addplot {x^3};‎
 ‎\end{axis}‎
‎\end{tikzpicture}‎
‎\end{document}
  • do you want to convert an .avi file to .eps? – percusse Apr 9 '12 at 8:41
  • Will \centering{\resizebox{1\textwidth}{!}{your tikz file}} be useful? You have to include graphicx package for this. – user11232 Apr 9 '12 at 8:56
  • @HarishKumar Could you post this as an answer (with a little explanation)? – Joseph Wright May 6 '12 at 8:11
1

To resize an image or picture to desired dimensions, you can either use \resizebox from graphicx package or adjustbox from adjustbox package.

The syntax for resizebox is

\resizebox{width}{height}{your tikz file}

If you want to keep the aspect ration the height can be replaced by !.

The full code will be

\usepackage{graphicx}
...
...
...
\begingroup
\centering
{\resizebox{10cm}{10cm}{
\begin{tikzpicture}‎
 ‎\begin{axis}[‎
   ‎xlabel={$x$}‎,
   ‎ylabel={\textbf{ $f(x)$‎ }}
   ]
   ‎\addplot {x^2};‎
   ‎\addplot {x^3};‎
 ‎\end{axis}‎
‎\end{tikzpicture}‎‎}}
\endgroup

But giving both width and height as 10cm may not keep the aspect ratio intact. Hence putting \resizebox{10cm}{!}{... will adjust the height so as to keep the aspect ratio.

The adjustbox may be used as

\usepackage{adjustbox}
...
...
...

\begin{adjustbox}{width=10cm,height=10cm}
  \begin{tikzpicture}
    % ..
  \end{tikzpicture}
\end{adjustbox}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.