\gdef\mpxshipout{\shipout\hbox\bgroup
  \setbox0=\hbox\bgroup}
\gdef\stopmpxshipout{\egroup  \dimen0=\ht0 \advance\dimen0\dp0
  \dimen1=\ht0 \dimen2=\dp0
  \setbox0=\hbox\bgroup
    \box0
    \ifnum\dimen0>0 \vrule width1sp height\dimen1 depth\dimen2 
    \else \vrule width1sp height1sp depth0sp\relax
    \fi\egroup
  \ht0=0pt \dp0=0pt \box0 \egroup}
\mpxshipout% line 9 ./smp.mp
A Curve $y=\sqrt{x}$%
\stopmpxshipout
\mpxshipout% line 10 ./smp.mp
$x$-axis%
\stopmpxshipout
\mpxshipout% line 11 ./smp.mp
$y$-axis%
\stopmpxshipout
\mpxshipout% line 12 ./smp.mp
Origin $O$%
\stopmpxshipout
\end{document}
