22

I want to remove ticks from the top and right axes of the bounding box of a plot generated with pgfplots. Any help appreciated.

Here is sample code which generates unwanted ticks.

\documentclass{article}
\usepackage{pgfplots,siunitx}
\pgfplotsset{compat=1.8}

\pgfplotstableread{
celc fahr
0  32
20 68
40 104
60 140
80 176
100 212
}\mytable


\begin{document}
\begin{tikzpicture}
    \begin{axis}[xlabel={\si{\degreeCelsius}},
                 ylabel={\si{\degree F}}]
    \addplot table \mytable;
    \end{axis}
\end{tikzpicture}
\end{document}

The result, with unwanted ticks in top and right:

example

I realize this sounds very basic but a search for examples to guide me has not panned out.

4
  • Search also the manual with axis lines.
    – percusse
    Jul 24, 2013 at 15:08
  • @Jake I do mean remove from top and right. I tried tick pos=right but this turns off ticks on the left y line AND the bottom line and sets the tick label on the top x axis.
    – Buck Thorn
    Jul 24, 2013 at 15:13
  • @Jake: to clarify, the plot shown above places the y label and y tick labels on the left side which is also not what I want but was readily fixed with y dir = reverse.
    – Buck Thorn
    Jul 24, 2013 at 15:22
  • 1
    @Jake: Thanks for your help, I made the edits you recommended. Sorry also about the confusion, the example shown is a watered down version of what I want to do. And no, I did not use y dir = reverse, instead I used yticklabel pos=right, I mixed those up in my answer.
    – Buck Thorn
    Jul 24, 2013 at 15:30

1 Answer 1

25

You can use the xtick pos, ytick pos keys:

\documentclass{article}
\usepackage{pgfplots,siunitx}
\pgfplotsset{compat=1.8}

\pgfplotstableread{
celc fahr
0  32
20 68
40 104
60 140
80 176
100 212
}\mytable


\begin{document}
\begin{tikzpicture}
    \begin{axis}[xlabel={\si{\degreeCelsius}},
                 ylabel={\si{\degree F}},
xtick pos=left,
ytick pos=left]
    \addplot table \mytable;
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

4
  • 3
    ... or tick pos=left, which sets xtick pos=left and ytick pos=left simultaneously.
    – Jake
    Jul 24, 2013 at 15:20
  • @Jake yes; however, I wan't sure from the original description if Try Hard wanted left also for the y-axis (the question mentions "right"), so I decided to present both keys for individual control. Jul 24, 2013 at 15:26
  • Very intuitive that the bottom of x is on the left... Is there some logical reason behind this or did they just not want to handle x and y differently?
    – luator
    Sep 15, 2015 at 21:05
  • @luator Probably by coincidence, from pgfplots manual "Note that the keys left and bottom are aliases for lower." (i.e. they both correspond to smaller value of the coordinate)
    – user202729
    Apr 21 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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