# pgfplots axis scaling

Is it possible to define in pgfplots that y should correspond to Y cm in my plot?

I know how to do this in tkz-fct, so let me add an tkz-fct example to make more clear what I want:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{tkz-fct}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}[scale=.5]
\tkzInit[xmax=10,ystep=3,ymax=10]
\tkzAxeXY
\tkzGrid
\tkzFct[color=red, thick,domain=0:10]{\x}
\tkzFct[domain=0:10]{\x**2}
\end{tikzpicture}
\begin{tikzpicture}[scale=.5]
\tkzInit[xmax=10,ystep=1.5,ymax=10]
\tkzAxeXY
\tkzGrid
\tkzFct[color=red, thick,domain=0:10]{\x}
\tkzFct[domain=0:10]{\x**2}
\end{tikzpicture}
\end{document}


In one case 3 corresponds to 0.5 cm on the y-axis in the picture, in the other case 1.5 corresponds to 0.5 cm on the y axis. This is achieved by using the scale=0.5 option together with the ystep option.

Not that it is important for me to have grids as in the tkz-fct example.

-
Does how to maintain the ratio between two axis in pgfplots answer your question? –  Peter Grill Jan 2 '12 at 22:35

You can specify the length of the unit vectors using the keys x and y. In this case, you would use x=0.5cm, y=0.5cm/3 for the first plot and x=0.5cm, y=0.5cm/1.5.

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
samples=60,
domain=0:10, xmax=10.5,
restrict y to domain=0:10,
axis lines=left,
y=0.5cm/3,
x=0.5cm,
grid=both,
xtick={0,...,10},
ytick={0,3,...,9},
xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}
]
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
samples=60,
domain=0:10, xmax=10.5,
restrict y to domain=0:10,
axis lines=left,
y=0.5cm/1.5,
x=0.5cm,
grid=both,
xtick={0,...,10},
ytick={0,1.5,3,...,9},
xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}