I have the following plot

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,ylabel=$\sin x$,
axis x line*=box]
\addplot[blue,mark=none,
domain=-10:0,samples=40]
{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

But i want the x axis on top:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=6cm,compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,ylabel=$\sin x$,
axis x line*=top]
\addplot[blue,mark=none,
domain=-10:0,samples=40
]
{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

How do i get the line in the bottom back?

enter image description here

up vote 6 down vote accepted

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}

enter image description here

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.