# Scale Y and X axis in pgfplots

I made the following plot, and the numbers are print to close together. How can I scale the the y and x axis?

\begin{tikzpicture}
\begin{axis}[
axis y line=center,
axis x line=middle,
axis equal,
grid=both,
xmax=10,xmin=-10,
ymin=-10,ymax=10,
xlabel=$x$,ylabel=$y$,
xtick={-10,...,10},
ytick={-10,...,10},
]

\end{axis}
\end{tikzpicture}

• Are you going to ask every detail ? Or should I make a particular plot that you have in mind? :) – percusse Sep 19 '14 at 17:24
• Add width=15cm, to axis options. – user11232 Sep 20 '14 at 0:45
• @percusse Yes, I been asking too many questions in a few minutes... sorry I am in hurry because I need to submit an assignment :-) – milarepa Sep 20 '14 at 4:49
• @HarishKumar Thank you. width=15 will do. – milarepa Sep 20 '14 at 4:49
• @HarishKumar Do you want to answer, or is there a duplicate somewhere? – Torbjørn T. Sep 21 '14 at 7:23

pgfplots can adjust the distance between the tick labels as the width/height of the varies. Hence you can change the width (or height) of the plot by passing width = <dimen> to the axis options:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=15cm,               %% here, adjust as suitable
%axis y line=center,
%axis x line=middle,
axis lines = middle,  %% instead of above two lines this one is enough
scaled ticks=false,
axis equal,
grid=major,
xmax=9,xmin=-9,
ymin=-10,ymax=10,
xlabel=$x$,ylabel=$y$,
xtick={-10,...,10},
ytick={-10,...,10},
]

\end{axis}
\end{tikzpicture}
\end{document}


The pdf such generated can be included in the main document using \includegraphics. If you want a uniform width for all the graphs, add it to the \pgfplotsset like

\pgfplotsset{width=15cm}


On ther other hand, you can define a style like

\pgfplotsset{
small/.style={
width=12cm,
height=,
tick label style={font=\tiny},
label style={font=\small},
max space between ticks=35,
}
}


and use it to maintain consistency:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\pgfplotsset{
small/.style={
width=12cm,
height=,
tick label style={font=\tiny},
label style={font=\small},
max space between ticks=35,
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
small,             %% here
%axis y line=center,
%axis x line=middle,
axis lines = middle,  %% instead of above two lines this one is enough
scaled ticks=false,
axis equal,
grid=major,
tick label/.style={font=\large},
xmax=9,xmin=-9,
ymin=-10,ymax=10,
xlabel=$x$,ylabel=$y$,
xtick={-10,...,10},
ytick={-10,...,10},
]

\end{axis}
\end{tikzpicture}
\end{document}


Refer to section 4.10.2, page 248 of pgfplots manual for more details.

• How can we make the ticks multiples of pi such as -2pi,-pi,0,pi,2pi? – bkarpuz Jul 5 '15 at 19:27

A solution with PSTricks just 4 fun.

\documentclass[pstricks,border=15pt,12pt]{standalone}
\usepackage{pst-plot}

\begin{document}
\begin{psgraph}[Dx=2,Dy=2]{->}(0,0)(-10,-10)(10,10){18cm}{12cm}
\psline[linecolor=blue]{*-*}(-3,3)(5,-3)
\end{psgraph}
\end{document}