How do I get the x axis on top but keep a line on the bottom
The line is there, but it might get confused with the border of the standalone image; you can give some value to border
if you want to distinguish it clearly:
\documentclass[border = 1pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=6cm,compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,ylabel=$\sin x$,
axis x line*=top]
\draw (axis description cs:0,0) -- (axis description cs:1,0);
\addplot[blue,mark=none,
domain=-10:0,samples=40
]
{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}
The option border=1pt
adds a little border (1pt
wide) on the four sides; to add the border only on the bottom and left sides, use border={0pt 1pt 1pt 0pt}
instead.
You seem only to want to move ticks. This can be achieved with xtick pos=upper,xticklabel pos=upper
.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=6cm,compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,ylabel=$\sin x$,
xtick pos=upper,xticklabel pos=upper]
\addplot[blue,mark=none,
domain=-10:0,samples=40
]
{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}