[Tex/LaTex] How to set the size in Octave, using Gnuplot for graphics from Octave

gnuplotoctaveplottikz-pgf

I am using Octave for all my calculations and plotting. By telling Octave

graphics_toolkit gnuplot

I can create a *.tex-document by

print -dtikz filename.tex

Which I can then use by

\input{filename}

In combination with

\usepackage{gnuplot-lua-tikz}
\usepackage{graphicx}
\usepackage{pgfsys}
\usepackage{keyval}
\usepackage{xcolor}
\usepackage{tikz}

Only problem is the size of the graph. During my long path to the above findings, I remember an error message saying that gnuplot uses a standard graph size of 560 by 420 pt. In LaTeX, I usually use something like

width = 0.9\textwidth

for non-*.tex graphs and I would like my plots to be approximately that large, because I would not like to fumble around with scaling factors or other parameters. That can sometimes mess up the relative positions of the single graphics items.

How do I change the plot size that Gnuplot creates from Octave?

Best Answer

When using \input{...} as a way of including figures made by Octave or gnuplot you may rescale the image using \resizebox{x}{y}{\input{...}}, where x and y are the required image dimensions in whatever units that you wish. The usage you would like to have requires keeping proportions constant, which would mean typing

\resizebox{0.9\textwidth}{!}{\input{plot}}

where the ! fills the missing height to keep the overall proportions constant. This worked throughout my LaTeX-aware life. However, this does not necessarily look nice, because the image will not be of appropriate scale: text might be minute, figure illegible, etc. If you wish to instead create the figure to have correct size directly in Octave, you should use the papersize property:

h = figure();

% plot your figure here

set(h, "papersize", [100, 100]);

The units used are points. Alternatively, you may use the -Sx,y switch of the print command; the two approaches are equivalent, but I think changing the figure properties is more rewarding and definitely more general, hence powerful.