Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a TikZ/PGF axis enviroment where by default numbers are shown along the ticks.

I want it to look like this:

Axis without tick numbers

(Axis without tick numbers)

I found out how to modify the ticks itself using something like

    x tick label style={major tick length=0pt}

in the options of an axis environment. But I couldn't find out how to modify the numbers along the ticks itself. Isn't there an option to hide them?

My current code to generate the 1st example:

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\usepackage{pgfplots}
\begin{document}
  \begin{tikzpicture}
    \begin{axis}[
      title={Test Axis},
      xlabel={Test X Label},
      ylabel={Test Y Label},
    ]
    \end{axis}
  \end{tikzpicture}
\end{document}
share|improve this question
    
Just thought, that it would maybe work defining 'empty' coords like this: "x coords={}" But unfortunately it didn't help. Any other ideas? –  eliasp Nov 28 '10 at 20:10
    
Turns out, 'x coords' is completely invalid. What I actually meant is "xtick={}". –  eliasp Nov 28 '10 at 20:17

2 Answers 2

up vote 13 down vote accepted

Just add yticklabels={,,} to the options for the axis environment. Your example then looks like shown below.

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\usepackage{pgfplots}
\begin{document}
  \begin{tikzpicture}
    \begin{axis}[%
      title={Test Axis},
      xlabel={Test X Label},
      ylabel={Test Y Label},
      yticklabels={,,}
    ]
    \end{axis}
  \end{tikzpicture}
\end{document}

This feature is documented in Section 4.14.2 (Tick Alignment: Positions and Shifts) on page 180 of the pgfplots 1.4.1 manual. Quite hidden in the last example of the mentioned section.

share|improve this answer
    
Thanks a lot. That's the easiest solution so far, although it still requires to move the axis label manually, as it isn't repositioned although the labels are gone now. For me it also worked using "yticklabels={}", is there a specific reason for using "yticklabels={,,}"? –  eliasp Nov 28 '10 at 21:50
    
I just read in this form in the manual. But good to know that an empty pair of braces also works. The manual positioning of the y-label is annoying but at the moment seems to be without alternative. Perhaps it's on the To-Do-list of the package maintainer. –  Thorsten Donig Nov 28 '10 at 21:58
    
@Thorsten actually, the manual positioning /was/ on the to-do-list. However, to maintain backwards compatibility, it has not been fixed automatically. Adding \pgfplotsset{compat=1.3} (or a more recent choice like 1.4 or 1.5) will automatically move the axis labels. –  Christian Feuersänger Jul 30 '11 at 18:41

The line

\pgfplotsset{ticks=none}

removes both ticks an labels.

Regarding hiding only the tick labels: one idea is to set the tick label color to the backround color. For example:

\pgfplotsset{tick label style={color=white},
  label style={font=\small},
  legend style={font=\small}

To shift the axis label, additionally modify the corresponding style, for example:

\pgfplotsset{every axis x label/.style={
  at={(0.5,0)},
  below,
  yshift=-5pt}}

Adjust the yshift parameter. Similar for the y axis.

\pgfplotsset{every axis y label/.style={
  at={(0,0.5)},
  xshift=-15pt,
  rotate=90}}

alt text

share|improve this answer
    
Ok, this workaround achieves my goal partially - the ticks + tick numbers are gone. The problem with this solution: The position of the axis label doesn't change as if the items would be really hidden. –  eliasp Nov 28 '10 at 20:21
1  
No problem, additionally modify x label/.style, I'll edit the answer. –  Stefan Kottwitz Nov 28 '10 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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