# pgfplots y=x graph not rendering all points

        \begin{tikzpicture}[baseline={([yshift=-1em] current bounding box.north)}]
\begin{axis}
[
x = 0.75cm,
y = 0.75cm,
xlabel = $x$,
ylabel = $y$,
xmin = -10,
xmax = 10,
restrict x to domain = -10:10,
ymin = -10,
ymax = 10,
restrict y to domain = -10:10,
axis x line = middle,
axis y line = middle,
]
\legend{$y = x$};
\end{axis}
\end{tikzpicture}


Why does the graph only render from (-5,-5) to (5,5)? It should be (-10,-10) to (10,10)

-
By default domain=-5:5 I think. – Torbjørn T. Apr 10 '14 at 19:48
Wow you were right. What is the purpose of setting the x and y domains separately then? – No_name Apr 10 '14 at 19:50
restrict to domain does not set the domains directly. What they do is to filter out values above or below the given interval. I'll add an answer in a bit. – Torbjørn T. Apr 10 '14 at 20:02

The restrict <x/y> to domain keys does not set the domain used for calculating y values, that is done by the domain key. The default value for domain is -5:5, meaning that functions are evaluated for -5 <= x <= 5.

Here is a quote from pgfplots' manual about the restrict keys:

These keys append x (or y or z) coordinate filters to restrict the respective coordinate to a domain. The versions without star (like restrict x to domain) will assign the value -inf if the coordinate is below min and +inf if the coordinate is above max . The starred versions (like restrict x to domain*) will truncate coordinates to [min, max], i.e. they assign the value min if the coordinate falls outside of the lower limit and max if the value falls outside of the upper limit.

The example from the manual has the plot of tan(x) over several cycles.

\documentclass[tikz,border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
restrict y to domain=-10:10,
samples=1000,
% some fine-tuning for the display:
width=10cm, height=210pt,
xmin=-4.7124, xmax=4.7124,
xtick={-4.7124,-1.5708,...,10},
xticklabels={$-\frac32 \pi$,$-\pi/2$,$\pi/2$,$\frac32 \pi$},
axis x line=center,
axis y line=center]

\legend{$\tan(x)$}
\end{axis}
\end{tikzpicture}
\end{document}


Hence, for your example the restrict ... keys are not really needed, and to get the plot for -10 < x 10, add domain=-10:10:

\documentclass[tikz,border=5mm,convert={false,density=100}]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[baseline={([yshift=-1em] current bounding box.north)}]
\begin{axis}
[
x = 0.75cm,
y = 0.75cm,
xlabel = $x$,
ylabel = $y$,
xmin = -10,
xmax = 10,
ymin = -10,
ymax = 10,
domain=-10:10,
axis lines = middle,
]
\legend{$y = x$};