1

I've looked at many similar questions but none describe quite what I'm trying to do. I would like to hide all the tick-marks on my axis except for one, under which I have a custom label. Here's a MWE:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
     \begin{tikzpicture}
            \begin{axis}[
                xticklabels = {}, xtick style = {draw=none},
                yticklabels = {}, ytick style = {draw=none},
                axis lines = middle, 
                ymin = -3, ymax = 3,  
                xmin = -3, xmax = 3,  
                extra x ticks={1},
                % extra x tick style = {grid=major},
                extra x tick labels = {$X_\alpha$}
                ]
            \end{axis}
        \end{tikzpicture}
\end{document}

Result of the above code

Removing the tick-marks on an entire axis is simple, but I wonder if there's a way to either exclude a particular one or maybe add it back after. The closest thing I could find was the commented line which adds a faint vertical line.

enter image description here

2
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – jlab
    Commented Apr 3 at 17:27
  • Sorry, I din't realise. I'll fix it. Thanks for pointing it out Commented Apr 3 at 20:09

1 Answer 1

0

The way you remove the ticks is not the best. Instead of

xticklabels = {}, xtick style = {draw=none},
yticklabels = {}, ytick style = {draw=none},

which don't remove the ticks, but hide them, prefer

xtick = \empty,
ytick = \empty,

In this way the extra x ticks will get its tick-mark.

In your case, you should simply set the desired ticks by hand:

xtick = {1},
xticklabels={$X_\alpha$},

Example:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
     \begin{tikzpicture}
            \begin{axis}[
                xtick = {1,1.5},
                xticklabels={$X_\alpha$, $X_\beta$},
                ytick = \empty,
                axis lines = middle,
                ymin = -3, ymax = 3,
                xmin = -3, xmax = 3,
                ]
            \end{axis}
        \end{tikzpicture}
\end{document}

manually set x labels

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .