EDIT: I completely rephrase the question. Consider the following MWE:
\documentclass{article}
\usepackage{showframe}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[height=\textheight,width=\textwidth,scale only axis]
\addplot {2^x};
\end{axis}
\end{tikzpicture}
\end{document}
with the key scale only axis, you can see that both axes (x and y) have exactly the dimensions of my text page and labels etc, don't fit in there anymore. If I remove it, the axis environment gets scaled down in both dimensions so that everything fits on the page.
Now my question is if I can apply that key scale only axis only to the y axis. For example, because I want the plot to take the maximum width in x direction without going over the margins (so x dimension without scale only axis) but the axis to have an exact height of, say 5cm (so the option scale only axis would be needed for y).
In order to check if it is done right, I would like to have the example above where to one dimension the key is applied and to the other not.
OLD (original) QUESTION:
in pgfplots, is it possible to apply the key scale only axis only to the y axis?
The reason why I ask is that I would like to give the overall width of the plot (including labels, etc), but need the axis to be exactly 5cm high.
width=x cmandheight=5 cmkeys – percusse Mar 30 '16 at 14:53scale only axisfor the y axis and the behaviour without for the x axis. Is this possible? – riddleculous Mar 30 '16 at 15:09scale only axiscan give different results. Try\begin{axis}[height=5cm,width=4cm,scale only axis,]\addplot {2^x};\end{axis}which is what you want. – percusse Mar 30 '16 at 15:44scale only axis=trueandscale only axis=falseis a fixed length of45pt: PGFPlots doesn't actually take into account how much space the labels and titles take up. So the (somewhat disenchanting) answer to your question is: usewidth=\textwidth, height=5cm+45ptor (equivalently)scale only axis, width=\textwidth-45pt, height=5cm– Jake Mar 30 '16 at 20:2245pt". There's a more involved approach using thtikzscalepackage that originated at http://tex.stackexchange.com/questions/36297/pgfplots-how-can-i-scale-to-text-width – Jake Mar 31 '16 at 07:11