Q:

Dimension too large in pgf plot

I am trying to create a pgf plot which includes (among others) a constant function f(x)=1. My x-axis should be restricted to some range (see below), and there is also a restriction on the y-axis. This is the minimal code that reproduces the issue:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin=0,
    xmax=.1,
    ymin=0,
    ymax=2]
    \addplot {1};
\end{axis}
\end{tikzpicture}
\end{document}

This code produces the error
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)         <7> on input line 11.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)         <5> on input line 11.
! Dimension too large.
<recently read> \pgf@xx

l.11           \end{axis}

I can't work with sizes bigger than about 19 feet.
Continue and I'll use the largest value I can.
! Dimension too large.

The last seven lines of the error message repeat 5 times. This happens no matter what values I use for the ymin and ymax parameters, but only for certain xmin and xmax. From trying different values, my guess would be that xmin-xmax has to be greater than approximately 0.15 for LaTeX to compile this successfully, but in my use case it has to be a range from xmin=.0005 to xmax=.0027.
Why does LaTeX throw an error when the range is too small (or is there something else wrong with my code)?
~ $ pdflatex -version
pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)

A:

You need to tell pgfplots that you are plotting an expression, and give it a domain:
 \addplot expression[domain=0:1]{1};

% arara: pdflatex
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin=0,
    xmax=.1,
    ymin=0,
    ymax=2]
    \addplot expression[domain=0:1]{1};
\end{axis}
\end{tikzpicture}
\end{document}

