I have a problem when I try to set width and height of the axis environment in a tikzpicture. Consider the following MWE:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=2,
ymin=0, ymax=3,
width=2\textwidth,
height=3\textwidth,
xmajorticks=false,
ymajorticks=false,
xmajorgrids,
ymajorgrids,
]
\end{axis}
\end{tikzpicture}
\end{document}
Why is it that with this code the output figure has indeed aspect ratio (close to) 3:2:
but if I change the lines
width=2\textwidth,
height=3\textwidth,
to
width=2\textwidth,
height=3\textwidth,
the output I get is skewed (the aspect ratio is something around 2.5:1) (which, btw, can also be seen by the fact that the grid lines no longer create squares but rectangles)
I tried reading the manual, but I didn't find anything (I probably didn't look for the right keyword).
What am I missing?
EDIT
sorry, I shouldn't post when it's this late. What I meant to write was:
but if I change the lines
width=2\textwidth,
height=3\textwidth,
to
width=0.2\textwidth,
height=0.3\textwidth,
the output I get is skewed.
And actually, this applies to any other number, for that matter. If I keep the aspect ratio fixed but change the absolute values for width and height, the resulting picture will be more skewed the smaller the values I use
Sorry again for the troubles.
Best Answer
I found the solution. It was clearly stated in the pgfplots manual, it was just a matter of finding it:
So, to have the proper aspect ratio for all sizes, simply add
scale only axis
to the option keys for theaxis
environment.