TITLE: Are morphisms from affine schemes to arbitrary schemes affine morphisms?
QUESTION [19 upvotes]: To put this question in precise language, let $X$ be an affine scheme, and $Y$ be an arbitrary scheme, and $f : X \rightarrow Y$ a morphism from $X$ to $Y$.  Does it follow that $f$ is an affine morphism of schemes?  While all cases are interesting, a counterexample that has both $X$ and $Y$ noetherian would be nice.

REPLY [46 votes]: Though it is not true in general, it is true whenever $Y$ is separated. The map $f$ from
$X$ to $Y$ factors as a composition
$$ X \stackrel{f'}{\rightarrow} X \times Y \stackrel{f''}{\rightarrow} Y$$
The map $f''$ is a pullback of the projection map from $X$ to a point
(or Spec $\mathbb{Z}$, or whatever base you are working over), and therefore affine.
The map $f'$ is a pullback of the diagonal $Y \rightarrow Y \times Y$, and therefore a closed immersion if $Y$ is separated (and in particular affine).

REPLY [35 votes]: No, here is  an example of a morphism $f:X\to Y$ which is not affine although $X$ is affine.
Take $X=\mathbb A^2_k$, the affine plane over the field $k$ and for $Y$ the notorious plane with origin doubled:   $Y=Y_1\cup Y_2$ with $Y_i\simeq \mathbb A^2_k$ open in $Y$ and $Y\setminus Y_i= \lbrace O_i\rbrace$, a  closed rational point of $Y$.
We take for $f:X\to Y$ the map sending $X$ isomorphically to $Y_1$ in the obvious way.  
Then, although the scheme $X$ is affine, the morphism  $f$ is not affine because the inverse image $f^{-1}(Y_2)$of the affine open subscheme $Y_2\subset Y$ is
 $X \setminus \lbrace 0 \rbrace=\mathbb A^2_k \setminus \lbrace 0 \rbrace$, the affine plane with origin deleted, well known not to be affine.